Search in sources :

Example 11 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.

the class NoteController method getNoteCSSStyle.

protected String getNoteCSSStyle(ModeController modeController, NodeModel node, float zoom, boolean asHtmlFragment) {
    final StringBuilder rule = new StringBuilder();
    // set default font for notes:
    final NodeStyleController style = (NodeStyleController) Controller.getCurrentModeController().getExtension(NodeStyleController.class);
    MapModel map = modeController.getController().getMap();
    if (map != null) {
        final MapStyleModel model = MapStyleModel.getExtension(map);
        final NodeModel noteStyleNode = model.getStyleNodeSafe(MapStyleModel.NOTE_STYLE);
        final Font noteFont = style.getFont(noteStyleNode);
        Color noteBackground = style.getBackgroundColor(noteStyleNode);
        Color noteForeground = style.getColor(noteStyleNode);
        final int alignment = style.getHorizontalTextAlignment(noteStyleNode).swingConstant;
        final CssRuleBuilder cssRuleBuilder = new CssRuleBuilder();
        if (asHtmlFragment)
            cssRuleBuilder.withHTMLFont(noteFont);
        else
            cssRuleBuilder.withCSSFont(noteFont);
        cssRuleBuilder.withColor(noteForeground).withBackground(noteBackground).withAlignment(alignment);
        if (asHtmlFragment)
            cssRuleBuilder.withMaxWidthAsPt(zoom, NodeSizeModel.getMaxNodeWidth(noteStyleNode), style.getMaxWidth(node));
        rule.append(cssRuleBuilder);
    }
    return rule.toString();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) CssRuleBuilder(org.freeplane.core.ui.components.html.CssRuleBuilder) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapModel(org.freeplane.features.map.MapModel) Font(java.awt.Font)

Example 12 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController 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 13 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.

the class UserPropertiesUpdater method importOldDefaultStyle.

void importOldDefaultStyle() {
    final ModeController modeController = Controller.getCurrentController().getModeController(MModeController.MODENAME);
    MFileManager fm = MFileManager.getController(modeController);
    final String standardTemplateName = fm.getStandardTemplateName();
    final File userDefault;
    final File absolute = new File(standardTemplateName);
    if (absolute.isAbsolute())
        userDefault = absolute;
    else {
        final File userTemplates = fm.defaultUserTemplateDir();
        userDefault = new File(userTemplates, standardTemplateName);
    }
    if (userDefault.exists()) {
        return;
    }
    userDefault.getParentFile().mkdirs();
    if (!userDefault.getParentFile().exists()) {
        return;
    }
    MapModel defaultStyleMap = new MapModel();
    final File allUserTemplates = fm.defaultStandardTemplateDir();
    final File standardTemplate = new File(allUserTemplates, "standard.mm");
    try {
        fm.loadCatchExceptions(standardTemplate.toURL(), defaultStyleMap);
    } catch (Exception e) {
        LogUtils.warn(e);
        try {
            fm.loadCatchExceptions(ResourceController.getResourceController().getResource("/styles/viewer_standard.mm"), defaultStyleMap);
        } catch (Exception e2) {
            defaultStyleMap.createNewRoot();
            LogUtils.severe(e);
        }
    }
    final NodeStyleController nodeStyleController = NodeStyleController.getController(modeController);
    updateDefaultStyle(nodeStyleController, defaultStyleMap);
    updateNoteStyle(nodeStyleController, defaultStyleMap);
    try {
        fm.writeToFile(defaultStyleMap, userDefault);
    } catch (IOException e) {
    }
}
Also used : NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MapModel(org.freeplane.features.map.MapModel) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException)

Example 14 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController 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, false);
    modeController.setUserInputListenerFactory(userInputListenerFactory);
    controller.addModeController(modeController);
    controller.selectModeForBuild(modeController);
    new MapController(modeController);
    IconController.install(new IconController(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());
    TextController.install(new TextController(modeController));
    LinkController.install(new LinkController());
    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.addMenuContributor(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", ViewController.BOTTOM, 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();
    new CloneStateIconSupplier().registerStateIconProvider();
    return modeController;
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) ClipboardController(org.freeplane.features.clipboard.ClipboardController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) BModeController(org.freeplane.features.mode.browsemode.BModeController) 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) CloneStateIconSupplier(org.freeplane.features.map.CloneStateIconSupplier) 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) BModeController(org.freeplane.features.mode.browsemode.BModeController) 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 15 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.

the class AttributeTable method getPreferredScrollableViewportSize.

@Override
public Dimension getPreferredScrollableViewportSize() {
    if (!isValid()) {
        validate();
    }
    final Dimension dimension = super.getPreferredSize();
    NodeView nodeView = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, this);
    if (nodeView != null) {
        final MapView map = nodeView.getMap();
        final ModeController modeController = map.getModeController();
        final NodeStyleController nsc = NodeStyleController.getController(modeController);
        dimension.width = Math.min(map.getZoomed(nsc.getMaxWidth(nodeView.getModel())), dimension.width);
        dimension.height = Math.min(map.getZoomed(AttributeTable.MAX_HEIGTH) - getTableHeaderHeight(), dimension.height);
    } else {
        dimension.width = Math.min(MAX_WIDTH, dimension.width);
        dimension.height = Math.min(MAX_HEIGTH, dimension.height);
    }
    return dimension;
}
Also used : NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) MapView(org.freeplane.view.swing.map.MapView) Dimension(java.awt.Dimension) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView)

Aggregations

NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)18 ModeController (org.freeplane.features.mode.ModeController)8 Color (java.awt.Color)5 Dimension (java.awt.Dimension)5 NodeModel (org.freeplane.features.map.NodeModel)5 Font (java.awt.Font)4 CloudController (org.freeplane.features.cloud.CloudController)4 EdgeController (org.freeplane.features.edge.EdgeController)4 MapModel (org.freeplane.features.map.MapModel)4 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)4 Component (java.awt.Component)3 Point (java.awt.Point)3 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