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