use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class MoveToRootAction method actionPerformed.
public void actionPerformed(final ActionEvent event) {
Controller ctrl = Controller.getCurrentController();
final IMapSelection selection = ctrl.getSelection();
if (selection != null) {
final NodeView selectedComponent = (NodeView) ctrl.getMapViewManager().getSelectedComponent();
if (!selectedComponent.focused() && java.awt.EventQueue.getCurrentEvent() instanceof KeyEvent)
selectedComponent.requestFocusInWindow();
else
selection.selectRoot();
}
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class LastOpenedList method updateLastVisitedNodeId.
private void updateLastVisitedNodeId(final Component mapView) {
if (!(mapView instanceof MapView))
return;
final NodeView selected = ((MapView) mapView).getSelected();
final RecentFile recentFile = findRecentFileByMapModel(getMapModel(mapView));
if (selected != null && recentFile != null) {
NodeModel selectedNode = selected.getModel();
// if a map has never been visited restoration of the selection has not yet taken place
if (!selectedNode.isRoot())
recentFile.lastVisitedNodeId = selectedNode.getID();
}
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class AttributeTable method updateComponentFontAndColors.
private void updateComponentFontAndColors(final JComponent c) {
final NodeView nodeView = attributeView.getNodeView();
final MapView mapView = nodeView.getMap();
final ModeController modeController = mapView.getModeController();
final NodeStyleController style = (NodeStyleController) modeController.getExtension(NodeStyleController.class);
final MapStyleModel model = MapStyleModel.getExtension(mapView.getModel());
final NodeModel attributeStyleNode = model.getStyleNodeSafe(MapStyleModel.ATTRIBUTE_STYLE);
final Font font = style.getFont(attributeStyleNode);
c.setFont(font.deriveFont(UITools.FONT_SCALE_FACTOR * font.getSize2D()));
if (!SwingUtilities.isDescendingFrom(this, nodeView)) {
return;
}
final Color backgroundColor = NodeStyleModel.getBackgroundColor(attributeStyleNode);
if (backgroundColor != null) {
c.setOpaque(true);
c.setBackground(backgroundColor);
} else {
c.setBackground(nodeView.getBackgroundColor());
c.setOpaque(false);
}
c.setForeground(style.getColor(attributeStyleNode));
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class AttributeTable method updateGridColor.
private void updateGridColor() {
final NodeView nodeView = attributeView.getNodeView();
if (!SwingUtilities.isDescendingFrom(this, nodeView))
return;
final MapView mapView = nodeView.getMap();
final MapStyleModel model = MapStyleModel.getExtension(mapView.getModel());
final NodeModel attributeStyleNode = model.getStyleNodeSafe(MapStyleModel.ATTRIBUTE_STYLE);
final EdgeModel edge = EdgeModel.getModel(attributeStyleNode);
if (edge != null) {
final Color edgeColor = edge.getColor();
setGridAndBorderColor(edgeColor);
} else
this.gridColor = null;
}
use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.
the class MNodeMotionListener method calculateNewFreeNodeIndex.
private int calculateNewFreeNodeIndex(final NodeView nodeV) {
final NodeModel node = nodeV.getModel();
if (SummaryNode.isHidden(node))
return -1;
final boolean left = nodeV.isLeft();
final int nodeY = getRefY(nodeV);
final NodeView parent = nodeV.getParentView();
int newIndex = 0;
int oldIndex = -1;
int wrondSideCount = 0;
int hiddenNodeCount = 0;
final int childCount = node.getParentNode().getChildCount();
for (int i = 0; i < childCount; i++) {
final Component component = parent.getComponent(i);
if (!(component instanceof NodeView))
continue;
NodeView siblingV = (NodeView) component;
final NodeModel sibling = siblingV.getModel();
if (siblingV.isLeft() == left && !SummaryNode.isHidden(sibling) && getRefY(siblingV) > nodeY)
break;
else {
if (siblingV != nodeV) {
newIndex++;
if (siblingV.isLeft() != left)
wrondSideCount++;
else {
wrondSideCount = 0;
if (oldIndex >= 0 && SummaryNode.isHidden(sibling))
hiddenNodeCount++;
else
hiddenNodeCount = 0;
}
} else {
oldIndex = i;
}
}
}
final int result = newIndex - wrondSideCount - hiddenNodeCount;
if (result == oldIndex)
return -1;
return result;
}
Aggregations