Search in sources :

Example 1 with NodeView

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();
    }
}
Also used : KeyEvent(java.awt.event.KeyEvent) IMapSelection(org.freeplane.features.map.IMapSelection) NodeView(org.freeplane.view.swing.map.NodeView)

Example 2 with NodeView

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();
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapView(org.freeplane.view.swing.map.MapView) NodeView(org.freeplane.view.swing.map.NodeView)

Example 3 with NodeView

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));
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView) Font(java.awt.Font)

Example 4 with NodeView

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;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapView(org.freeplane.view.swing.map.MapView) NodeView(org.freeplane.view.swing.map.NodeView) EdgeModel(org.freeplane.features.edge.EdgeModel)

Example 5 with NodeView

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;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeView(org.freeplane.view.swing.map.NodeView) Component(java.awt.Component) Point(java.awt.Point)

Aggregations

NodeView (org.freeplane.view.swing.map.NodeView)43 NodeModel (org.freeplane.features.map.NodeModel)20 MapView (org.freeplane.view.swing.map.MapView)17 ModeController (org.freeplane.features.mode.ModeController)14 MainView (org.freeplane.view.swing.map.MainView)11 Point (java.awt.Point)8 INodeView (org.freeplane.features.map.INodeView)8 Controller (org.freeplane.features.mode.Controller)6 JPopupMenu (javax.swing.JPopupMenu)5 ResourceController (org.freeplane.core.resources.ResourceController)5 MapController (org.freeplane.features.map.MapController)5 MMapController (org.freeplane.features.map.mindmapmode.MMapController)5 Dimension (java.awt.Dimension)4 MTextController (org.freeplane.features.text.mindmapmode.MTextController)4 Color (java.awt.Color)3 Component (java.awt.Component)3 JComponent (javax.swing.JComponent)3 IMapSelection (org.freeplane.features.map.IMapSelection)3 LocationController (org.freeplane.features.nodelocation.LocationController)3 MLocationController (org.freeplane.features.nodelocation.mindmapmode.MLocationController)3