Search in sources :

Example 1 with EdgeController

use of org.freeplane.features.edge.EdgeController in project freeplane by freeplane.

the class FModeControllerFactory method createModeController.

public static FModeController createModeController() {
    final Controller controller = Controller.getCurrentController();
    modeController = new FModeController(controller);
    final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController, false);
    modeController.setUserInputListenerFactory(userInputListenerFactory);
    controller.addModeController(modeController);
    controller.selectModeForBuild(modeController);
    new FMapController(modeController);
    UrlManager.install(new UrlManager());
    MapIO.install(modeController);
    IconController.install(new IconController(modeController));
    NodeStyleController.install(new NodeStyleController(modeController));
    EdgeController.install(new EdgeController(modeController));
    TextController.install(new TextController(modeController));
    LinkController.install(new LinkController());
    CloudController.install(new CloudController(modeController));
    ClipboardController.install(new ClipboardController());
    LocationController.install(new LocationController());
    LogicalStyleController.install(new LogicalStyleController(modeController));
    MapStyle.install(true);
    NodeStyleController.getController().addShapeGetter(new Integer(0), new IPropertyHandler<String, NodeModel>() {

        public String getProperty(final NodeModel node, final String currentValue) {
            return "fork";
        }
    });
    modeController.addAction(new CenterAction());
    modeController.addAction(new OpenPathAction());
    userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
    final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
    FrameController frameController = (FrameController) controller.getViewController();
    UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
    userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
    userInputListenerFactory.addToolBar("/filter_toolbar", ViewController.BOTTOM, FilterController.getCurrentFilterController().getFilterToolbar());
    userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
    NodeHistory.install(modeController);
    return modeController;
}
Also used : OpenPathAction(org.freeplane.features.map.filemode.OpenPathAction) UrlManager(org.freeplane.features.url.UrlManager) ClipboardController(org.freeplane.features.clipboard.ClipboardController) EdgeController(org.freeplane.features.edge.EdgeController) TextController(org.freeplane.features.text.TextController) LinkController(org.freeplane.features.link.LinkController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) UserInputListenerFactory(org.freeplane.view.swing.ui.UserInputListenerFactory) LocationController(org.freeplane.features.nodelocation.LocationController) FMapController(org.freeplane.features.map.filemode.FMapController) ClipboardController(org.freeplane.features.clipboard.ClipboardController) FModeController(org.freeplane.features.mode.filemode.FModeController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) EdgeController(org.freeplane.features.edge.EdgeController) ViewController(org.freeplane.features.ui.ViewController) CloudController(org.freeplane.features.cloud.CloudController) LinkController(org.freeplane.features.link.LinkController) FilterController(org.freeplane.features.filter.FilterController) LocationController(org.freeplane.features.nodelocation.LocationController) FrameController(org.freeplane.features.ui.FrameController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) FMapController(org.freeplane.features.map.filemode.FMapController) JPopupMenu(javax.swing.JPopupMenu) IconController(org.freeplane.features.icon.IconController) CenterAction(org.freeplane.features.map.filemode.CenterAction) NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) CloudController(org.freeplane.features.cloud.CloudController) FModeController(org.freeplane.features.mode.filemode.FModeController) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) FrameController(org.freeplane.features.ui.FrameController)

Example 2 with EdgeController

use of org.freeplane.features.edge.EdgeController in project freeplane by freeplane.

the class NodeView method updateEdge.

private void updateEdge() {
    final EdgeController edgeController = EdgeController.getController(getMap().getModeController());
    this.edgeStyle = edgeController.getStyle(model, false);
    this.edgeWidth = edgeController.getWidth(model, false);
    this.edgeColor = edgeController.getColor(model, false);
}
Also used : EdgeController(org.freeplane.features.edge.EdgeController)

Example 3 with EdgeController

use of org.freeplane.features.edge.EdgeController in project freeplane by freeplane.

the class NodeView method getEdgeColor.

public Color getEdgeColor() {
    if (edgeColor.hasValue())
        return edgeColor.getValue();
    Rules rule = edgeColor.getRule();
    if (rule == EdgeController.Rules.BY_COLUMN) {
        final Color color = new AutomaticEdgeStyle(this).getColor();
        edgeColor.setCache(color);
        return color;
    }
    final NodeModel parentNode = model.getParentNode();
    if (rule == EdgeController.Rules.BY_BRANCH && parentNode.isRoot() || rule == EdgeController.Rules.BY_LEVEL) {
        final int index;
        if (rule == EdgeController.Rules.BY_BRANCH)
            index = parentNode.getIndex(model) + 1;
        else
            index = model.getNodeLevel(false) + (model.isHiddenSummary() ? 1 : 0);
        final MapModel mapModel = map.getModel();
        ModeController modeController = map.getModeController();
        EdgeController edgeController = modeController.getExtension(EdgeController.class);
        if (edgeController.areEdgeColorsAvailable(mapModel)) {
            Color color = edgeController.getEdgeColor(mapModel, index);
            edgeColor.setCache(color);
            return color;
        }
    } else if (rule == EdgeController.Rules.BY_PARENT) {
        final NodeView parentView = getParentView();
        if (parentView != null) {
            final Color color = parentView.getEdgeColor();
            return color;
        }
    }
    return Color.GRAY;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) AutomaticEdgeStyle(org.freeplane.view.swing.map.edge.AutomaticEdgeStyle) EdgeController(org.freeplane.features.edge.EdgeController) Color(java.awt.Color) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController) INodeView(org.freeplane.features.map.INodeView) Rules(org.freeplane.features.edge.EdgeController.Rules) Point(java.awt.Point)

Example 4 with EdgeController

use of org.freeplane.features.edge.EdgeController in project freeplane by freeplane.

the class BModeControllerFactory method createModeController.

public static BModeController createModeController() {
    final Controller controller = Controller.getCurrentController();
    modeController = new BModeController(controller);
    final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
    modeController.setUserInputListenerFactory(userInputListenerFactory);
    controller.addModeController(modeController);
    controller.selectModeForBuild(modeController);
    new MapController(modeController);
    new IconController(modeController).install(modeController);
    UrlManager.install(new UrlManager());
    MapIO.install(modeController);
    AttributeController.install(new AttributeController(modeController));
    NodeStyleController.install(new NodeStyleController(modeController));
    EdgeController.install(new EdgeController(modeController));
    CloudController.install(new CloudController(modeController));
    NoteController.install(new NoteController());
    new TextController(modeController).install(modeController);
    LinkController.install(new LinkController(modeController));
    LogicalStyleController.install(new LogicalStyleController(modeController));
    try {
        ClipboardController.install(new ClipboardController());
    } catch (final AccessControlException e) {
        LogUtils.warn("can not access system clipboard, clipboard controller disabled");
    }
    LocationController.install(new LocationController());
    SummaryNode.install();
    FreeNode.install();
    MapStyle.install(true);
    final BToolbarContributor toolbarContributor = new BToolbarContributor();
    modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_url", toolbarContributor);
    controller.getMapViewManager().addMapViewChangeListener(toolbarContributor);
    userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
    final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
    FrameController frameController = (FrameController) controller.getViewController();
    UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
    userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
    userInputListenerFactory.addToolBar("/filter_toolbar", FilterController.TOOLBAR_SIDE, FilterController.getController(controller).getFilterToolbar());
    userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
    FoldingController.install(new FoldingController());
    new ViewerController();
    EncryptionController.install(new EncryptionController(modeController));
    new AutomaticLayoutController();
    return modeController;
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) ClipboardController(org.freeplane.features.clipboard.ClipboardController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) LinkController(org.freeplane.features.link.LinkController) LocationController(org.freeplane.features.nodelocation.LocationController) ViewerController(org.freeplane.view.swing.features.filepreview.ViewerController) IconController(org.freeplane.features.icon.IconController) FoldingController(org.freeplane.features.map.FoldingController) FrameController(org.freeplane.features.ui.FrameController) NoteController(org.freeplane.features.note.NoteController) EdgeController(org.freeplane.features.edge.EdgeController) AttributeController(org.freeplane.features.attribute.AttributeController) TextController(org.freeplane.features.text.TextController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) UserInputListenerFactory(org.freeplane.view.swing.ui.UserInputListenerFactory) AccessControlException(java.security.AccessControlException) AttributeController(org.freeplane.features.attribute.AttributeController) EncryptionController(org.freeplane.features.encrypt.EncryptionController) ViewerController(org.freeplane.view.swing.features.filepreview.ViewerController) ClipboardController(org.freeplane.features.clipboard.ClipboardController) NoteController(org.freeplane.features.note.NoteController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) EdgeController(org.freeplane.features.edge.EdgeController) ViewController(org.freeplane.features.ui.ViewController) CloudController(org.freeplane.features.cloud.CloudController) LinkController(org.freeplane.features.link.LinkController) FilterController(org.freeplane.features.filter.FilterController) MapController(org.freeplane.features.map.MapController) LocationController(org.freeplane.features.nodelocation.LocationController) FoldingController(org.freeplane.features.map.FoldingController) FrameController(org.freeplane.features.ui.FrameController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) JPopupMenu(javax.swing.JPopupMenu) MapController(org.freeplane.features.map.MapController) EncryptionController(org.freeplane.features.encrypt.EncryptionController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) CloudController(org.freeplane.features.cloud.CloudController) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar)

Example 5 with EdgeController

use of org.freeplane.features.edge.EdgeController in project freeplane by freeplane.

the class StyleEditorPanel method setStyle.

public void setStyle(final NodeModel node) {
    if (internalChange) {
        return;
    }
    internalChange = true;
    try {
        final LogicalStyleController logicalStyleController = LogicalStyleController.getController();
        if (addStyleBox) {
            final boolean isStyleSet = LogicalStyleModel.getStyle(node) != null;
            mSetStyle.setValue(isStyleSet);
            setStyleList(mMapStyleButton, logicalStyleController.getMapStyleNames(node, "\n"));
        }
        setStyleList(mNodeStyleButton, logicalStyleController.getNodeStyleNames(node, "\n"));
        final NodeStyleController styleController = NodeStyleController.getController();
        {
            final Color nodeColor = NodeStyleModel.getColor(node);
            final Color viewNodeColor = styleController.getColor(node);
            mSetNodeColor.setValue(nodeColor != null);
            mNodeColor.setColorValue(viewNodeColor);
        }
        {
            final Color color = NodeStyleModel.getBackgroundColor(node);
            final Color viewColor = styleController.getBackgroundColor(node);
            mSetNodeBackgroundColor.setValue(color != null);
            mNodeBackgroundColor.setColorValue(viewColor != null ? viewColor : Controller.getCurrentController().getMapViewManager().getBackgroundColor(node));
        }
        {
            final String shape = NodeStyleModel.getShape(node);
            final String viewShape = styleController.getShape(node);
            mSetNodeShape.setValue(shape != null);
            mNodeShape.setValue(viewShape);
        }
        final NodeSizeModel nodeSizeModel = NodeSizeModel.getModel(node);
        {
            final int width = nodeSizeModel != null ? nodeSizeModel.getMaxNodeWidth() : NodeSizeModel.NOT_SET;
            final int viewWidth = styleController.getMaxWidth(node);
            mSetMaxNodeWidth.setValue(width != NodeSizeModel.NOT_SET);
            mMaxNodeWidth.setValue(Integer.toString(viewWidth));
        }
        {
            final int width = nodeSizeModel != null ? nodeSizeModel.getMinNodeWidth() : NodeSizeModel.NOT_SET;
            final int viewWidth = styleController.getMinWidth(node);
            mSetMinNodeWidth.setValue(width != NodeSizeModel.NOT_SET);
            mMinNodeWidth.setValue(Integer.toString(viewWidth));
        }
        final EdgeController edgeController = EdgeController.getController();
        final EdgeModel edgeModel = EdgeModel.getModel(node);
        {
            final Color edgeColor = edgeModel != null ? edgeModel.getColor() : null;
            final Color viewColor = edgeController.getColor(node);
            mSetEdgeColor.setValue(edgeColor != null);
            mEdgeColor.setColorValue(viewColor);
        }
        {
            final EdgeStyle style = edgeModel != null ? edgeModel.getStyle() : null;
            final EdgeStyle viewStyle = edgeController.getStyle(node);
            mSetEdgeStyle.setValue(style != null);
            mEdgeStyle.setValue(viewStyle.toString());
        }
        {
            final int width = edgeModel != null ? edgeModel.getWidth() : EdgeModel.DEFAULT_WIDTH;
            final int viewWidth = edgeController.getWidth(node);
            mSetEdgeWidth.setValue(width != EdgeModel.DEFAULT_WIDTH);
            mEdgeWidth.setValue(Integer.toString(viewWidth));
        }
        {
            final CloudController cloudController = CloudController.getController();
            final CloudModel cloudModel = CloudModel.getModel(node);
            final Color viewCloudColor = cloudController.getColor(node);
            mSetCloud.setValue(cloudModel != null);
            mCloudColor.setColorValue(viewCloudColor);
            final CloudModel.Shape viewCloudShape = cloudController.getShape(node);
            mCloudShape.setValue(viewCloudShape != null ? viewCloudShape.toString() : CloudModel.Shape.ARC.toString());
        }
        {
            final String fontFamilyName = NodeStyleModel.getFontFamilyName(node);
            final String viewFontFamilyName = styleController.getFontFamilyName(node);
            mSetNodeFontName.setValue(fontFamilyName != null);
            mNodeFontName.setValue(viewFontFamilyName);
        }
        {
            final Integer fontSize = NodeStyleModel.getFontSize(node);
            final Integer viewfontSize = styleController.getFontSize(node);
            mSetNodeFontSize.setValue(fontSize != null);
            mNodeFontSize.setValue(viewfontSize.toString());
        }
        {
            final Boolean bold = NodeStyleModel.isBold(node);
            final Boolean viewbold = styleController.isBold(node);
            mSetNodeFontBold.setValue(bold != null);
            mNodeFontBold.setValue(viewbold);
        }
        {
            final Boolean italic = NodeStyleModel.isItalic(node);
            final Boolean viewitalic = styleController.isItalic(node);
            mSetNodeFontItalic.setValue(italic != null);
            mNodeFontItalic.setValue(viewitalic);
        }
        {
            final Boolean hyperlink = NodeLinks.formatNodeAsHyperlink(node);
            final Boolean viewhyperlink = LinkController.getController().formatNodeAsHyperlink(node);
            mSetNodeFontHyperlink.setValue(hyperlink != null);
            mNodeFontHyperlink.setValue(viewhyperlink);
        }
        {
            final Boolean nodeNumbering = NodeStyleModel.getNodeNumbering(node);
            final Boolean viewNodeNumbering = styleController.getNodeNumbering(node);
            mSetNodeNumbering.setValue(nodeNumbering != null);
            mNodeNumbering.setValue(viewNodeNumbering);
        }
        {
            String nodeFormat = NodeStyleModel.getNodeFormat(node);
            String viewNodeFormat = TextController.getController().getNodeFormat(node);
            mSetNodeFormat.setValue(nodeFormat != null);
            if (viewNodeFormat == null && node.getUserObject() instanceof IFormattedObject)
                viewNodeFormat = ((IFormattedObject) node.getUserObject()).getPattern();
            mNodeFormat.setValue(viewNodeFormat);
        }
        if (mAutomaticLayoutComboBox != null) {
            final ModeController modeController = Controller.getCurrentModeController();
            AutomaticLayoutController al = modeController.getExtension(AutomaticLayoutController.class);
            IExtension extension = al.getExtension(node);
            if (extension == null)
                mAutomaticLayoutComboBox.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
            else
                mAutomaticLayoutComboBox.setSelectedIndex(((AutomaticLayout) extension).ordinal());
        }
        if (mAutomaticEdgeColorCheckBox != null) {
            final ModeController modeController = Controller.getCurrentModeController();
            AutomaticEdgeColorHook al = (AutomaticEdgeColorHook) modeController.getExtension(AutomaticEdgeColorHook.class);
            mAutomaticEdgeColorCheckBox.setSelected(al.isActive(node));
        }
    } finally {
        internalChange = false;
    }
}
Also used : AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) EdgeController(org.freeplane.features.edge.EdgeController) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController) AutomaticEdgeColorHook(org.freeplane.features.edge.mindmapmode.AutomaticEdgeColorHook) AutomaticLayout(org.freeplane.features.styles.AutomaticLayout) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) Color(java.awt.Color) IFormattedObject(org.freeplane.features.format.IFormattedObject) ModeController(org.freeplane.features.mode.ModeController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) CloudController(org.freeplane.features.cloud.CloudController) MCloudController(org.freeplane.features.cloud.mindmapmode.MCloudController) NodeSizeModel(org.freeplane.features.nodestyle.NodeSizeModel) IExtension(org.freeplane.core.extension.IExtension) CloudModel(org.freeplane.features.cloud.CloudModel) EdgeStyle(org.freeplane.features.edge.EdgeStyle) EdgeModel(org.freeplane.features.edge.EdgeModel)

Aggregations

EdgeController (org.freeplane.features.edge.EdgeController)6 CloudController (org.freeplane.features.cloud.CloudController)4 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)4 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)4 JPopupMenu (javax.swing.JPopupMenu)3 FreeplaneToolBar (org.freeplane.core.ui.components.FreeplaneToolBar)3 ClipboardController (org.freeplane.features.clipboard.ClipboardController)3 FilterController (org.freeplane.features.filter.FilterController)3 IconController (org.freeplane.features.icon.IconController)3 LinkController (org.freeplane.features.link.LinkController)3 Controller (org.freeplane.features.mode.Controller)3 LocationController (org.freeplane.features.nodelocation.LocationController)3 AutomaticLayoutController (org.freeplane.features.styles.AutomaticLayoutController)3 TextController (org.freeplane.features.text.TextController)3 FrameController (org.freeplane.features.ui.FrameController)3 ViewController (org.freeplane.features.ui.ViewController)3 UrlManager (org.freeplane.features.url.UrlManager)3 UserInputListenerFactory (org.freeplane.view.swing.ui.UserInputListenerFactory)3 Color (java.awt.Color)2 AccessControlException (java.security.AccessControlException)2