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();
}
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;
}
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) {
}
}
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;
}
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;
}
Aggregations