use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class MapViewController method setMapTitles.
public void setMapTitles() {
final ModeController modeController = Controller.getCurrentModeController();
if (modeController == null) {
controller.getViewController().setTitle("");
return;
}
final Object[] messageArguments = { TextUtils.getText(("mode_" + modeController.getModeName())) };
final MessageFormat formatter = new MessageFormat(TextUtils.getText("mode_title"));
String frameTitle = formatter.format(messageArguments);
String viewName = "";
final MapModel model = getModel();
if (model != null) {
viewName = getMapViewComponent().getName();
frameTitle = viewName + ((model.isSaved() || model.isReadOnly()) ? "" : "*") + " - " + frameTitle + (model.isReadOnly() ? " (" + TextUtils.getText("read_only") + ")" : "");
final File file = model.getFile();
if (file != null) {
frameTitle += " " + file.getAbsolutePath();
}
}
controller.getViewController().setTitle(frameTitle);
modeController.getUserInputListenerFactory().updateMapList();
}
use of org.freeplane.features.map.MapModel 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.map.MapModel in project freeplane by freeplane.
the class EdgeController method getStyleEdgeColorRule.
private ObjectRule<Color, Rules> getStyleEdgeColorRule(NodeModel node) {
MapModel map = node.getMap();
Collection<IStyle> collection = LogicalStyleController.getController(modeController).getStyles(node);
final MapStyleModel styles = MapStyleModel.getExtension(map);
for (IStyle styleKey : collection) {
final NodeModel styleNode = styles.getStyleNode(styleKey);
if (styleNode == null) {
continue;
}
if (node != styleNode && map.getRootNode().containsExtension(AutomaticEdgeColor.class)) {
AutomaticLayoutController automaticLayoutController = modeController.getExtension(AutomaticLayoutController.class);
if (automaticLayoutController != null && automaticLayoutController.isAutomaticLevelStyle(styleNode)) {
continue;
}
}
ObjectRule<Color, Rules> nodeColor = getNodeColorRule(styleNode);
if (nodeColor != null)
return nodeColor;
}
return null;
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class FindAction method findNext.
void findNext(Direction direction) {
final MapModel map = Controller.getCurrentController().getMap();
final FoundNodes info = FoundNodes.get(map);
if (info.condition == null) {
displayNoPreviousFindMessage();
return;
}
final FilterController filterController = FilterController.getCurrentFilterController();
final NodeModel start = Controller.getCurrentController().getSelection().getSelected();
final NodeModel root = map.getNodeForID(info.rootID);
if (root == null) {
info.condition = null;
displayNoPreviousFindMessage();
return;
}
final NodeModel next = filterController.findNext(start, null, direction, info.condition);
if (next == null) {
displayNotFoundMessage(root, info.condition);
return;
}
info.displayFoundNode(next);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class FoundNodes method displayFoundNode.
/**
* Display a node in the display (used by find and the goto action by arrow
* link actions).
*/
void displayFoundNode(final NodeModel node) {
final MapModel map = node.getMap();
final LinkedList<String> nodesUnfoldedByDisplay = new LinkedList<String>();
NodeModel nodeOnPath = null;
for (nodeOnPath = node; nodeOnPath != null && !this.nodesUnfoldedByDisplay.contains(nodeOnPath.createID()); nodeOnPath = nodeOnPath.getParentNode()) {
if (Controller.getCurrentModeController().getMapController().isFolded(nodeOnPath)) {
nodesUnfoldedByDisplay.add(nodeOnPath.createID());
}
}
final ListIterator<String> oldPathIterator = this.nodesUnfoldedByDisplay.listIterator(this.nodesUnfoldedByDisplay.size());
while (oldPathIterator.hasPrevious()) {
final String oldPathNodeID = oldPathIterator.previous();
final NodeModel oldPathNode = map.getNodeForID(oldPathNodeID);
if (oldPathNode != null && oldPathNode.equals(nodeOnPath)) {
break;
}
oldPathIterator.remove();
if (oldPathNode != null) {
Controller.getCurrentModeController().getMapController().fold(oldPathNode);
}
}
this.nodesUnfoldedByDisplay.addAll(nodesUnfoldedByDisplay);
Controller.getCurrentModeController().getMapController().select(node);
}
Aggregations