Search in sources :

Example 61 with NodeModel

use of org.freeplane.features.map.NodeModel 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 62 with NodeModel

use of org.freeplane.features.map.NodeModel 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 63 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class MNodeDropListener method isFromDescencantNode.

private boolean isFromDescencantNode(final DropTargetDropEvent event) {
    final Transferable t = event.getTransferable();
    final List<NodeModel> transferData;
    try {
        transferData = getNodeObjects(t);
    } catch (Exception e) {
        return false;
    }
    final NodeModel node = ((MainView) event.getDropTargetContext().getComponent()).getNodeView().getModel();
    for (final NodeModel selected : transferData) {
        if ((node == selected) || node.isDescendantOf(selected))
            return true;
    }
    return false;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) Transferable(java.awt.datatransfer.Transferable) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException)

Example 64 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class MNodeDropListener method isFromSameMap.

private boolean isFromSameMap(final DropTargetDropEvent event) {
    final Transferable t = event.getTransferable();
    final List<NodeModel> transferData;
    try {
        transferData = getNodeObjects(t);
    } catch (Exception e) {
        return false;
    }
    final NodeModel node = ((MainView) event.getDropTargetContext().getComponent()).getNodeView().getModel();
    for (final NodeModel selected : transferData) {
        if (selected.getMap() != node.getMap())
            return false;
    }
    return true;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) Transferable(java.awt.datatransfer.Transferable) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException)

Example 65 with NodeModel

use of org.freeplane.features.map.NodeModel 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

NodeModel (org.freeplane.features.map.NodeModel)450 ModeController (org.freeplane.features.mode.ModeController)100 MapModel (org.freeplane.features.map.MapModel)53 Controller (org.freeplane.features.mode.Controller)46 MapStyleModel (org.freeplane.features.styles.MapStyleModel)46 MMapController (org.freeplane.features.map.mindmapmode.MMapController)39 MapController (org.freeplane.features.map.MapController)38 Point (java.awt.Point)37 IStyle (org.freeplane.features.styles.IStyle)36 IActor (org.freeplane.core.undo.IActor)34 IMapSelection (org.freeplane.features.map.IMapSelection)33 ArrayList (java.util.ArrayList)22 NodeView (org.freeplane.view.swing.map.NodeView)20 URI (java.net.URI)19 Color (java.awt.Color)18 Component (java.awt.Component)17 ResourceController (org.freeplane.core.resources.ResourceController)17 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)15