use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class MClipboardController method pasteStringWithoutRedisplay.
private void pasteStringWithoutRedisplay(final TextFragment[] textFragments, NodeModel parent, final boolean asSibling, final boolean isLeft) {
final MapModel map = parent.getMap();
int insertionIndex;
if (asSibling) {
NodeModel target = parent;
parent = parent.getParentNode();
insertionIndex = parent.getChildPosition(target);
} else {
insertionIndex = parent.getChildCount();
}
final ArrayList<NodeModel> parentNodes = new ArrayList<NodeModel>();
final ArrayList<Integer> parentNodesDepths = new ArrayList<Integer>();
parentNodes.add(parent);
parentNodesDepths.add(new Integer(-1));
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
for (int i = 0; i < textFragments.length; ++i) {
final TextFragment textFragment = textFragments[i];
String text = textFragment.text;
final String link = textFragment.link;
URI uri = null;
if (link != null) {
try {
URI linkUri = new URI(link);
uri = linkUri;
File absoluteFile = UrlManager.getController().getAbsoluteFile(map, uri);
if (absoluteFile != null) {
// if ("file".equals(linkUri.getScheme())) {
final File mapFile = map.getFile();
uri = LinkController.toLinkTypeDependantURI(mapFile, absoluteFile);
if (link.equals(text)) {
text = uri.toString();
}
}
} catch (Exception e) {
}
}
final NodeModel node = mapController.newNode(text, map);
if (uri != null) {
NodeLinks.createLinkExtension(node).setHyperLink(uri);
}
for (int j = parentNodes.size() - 1; j >= 0; --j) {
if (textFragment.depth > ((Integer) parentNodesDepths.get(j)).intValue()) {
for (int k = j + 1; k < parentNodes.size(); ++k) {
final NodeModel n = (NodeModel) parentNodes.get(k);
if (n.getParentNode() == null) {
mapController.insertNode(n, parent, insertionIndex++);
}
parentNodes.remove(k);
parentNodesDepths.remove(k);
}
final NodeModel target = (NodeModel) parentNodes.get(j);
node.setLeft(isLeft);
if (target != parent) {
target.setFolded(true);
target.insert(node, target.getChildCount());
}
parentNodes.add(node);
parentNodesDepths.add(new Integer(textFragment.depth));
break;
}
}
}
{
for (int k = 0; k < parentNodes.size(); ++k) {
final NodeModel n = (NodeModel) parentNodes.get(k);
if (map.getRootNode() != n && n.getParentNode() == null) {
mapController.insertNode(n, parent, insertionIndex++);
}
}
}
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class EdgeController method getStyleEdgeColor.
private Color getStyleEdgeColor(final MapModel map, final Collection<IStyle> collection) {
final MapStyleModel model = MapStyleModel.getExtension(map);
for (IStyle styleKey : collection) {
final NodeModel styleNode = model.getStyleNode(styleKey);
if (styleNode == null) {
continue;
}
final EdgeModel styleModel = EdgeModel.getModel(styleNode);
if (styleModel == null) {
continue;
}
final Color styleColor = styleModel.getColor();
if (styleColor == null) {
continue;
}
return styleColor;
}
return null;
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class CloudShapeAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
ModeController controller;
{
controller = Controller.getCurrentModeController();
final NodeModel selected = controller.getMapController().getSelectedNode();
final MCloudController cloudController = (MCloudController) CloudController.getController();
cloudController.setCloud(selected, true);
}
super.actionPerformed(e);
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class CloudShapeAction method setSelected.
@Override
public void setSelected() {
final NodeModel node = Controller.getCurrentModeController().getMapController().getSelectedNode();
final CloudModel model = CloudModel.getModel(node);
if (model != null) {
if (actionShape.equals(model.getShape())) {
setSelected(true);
return;
}
}
setSelected(false);
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class EdgeBuilder method endElement.
public void endElement(final Object parent, final String tag, final Object userObject, final XMLElement dom) {
/* attributes */
if (parent instanceof NodeModel) {
final NodeModel node = (NodeModel) parent;
if (userObject instanceof EdgeModel) {
final EdgeModel edge = (EdgeModel) userObject;
EdgeModel.setModel(node, edge);
}
return;
}
}
Aggregations