Search in sources :

Example 1 with NodeLinkModel

use of org.freeplane.features.link.NodeLinkModel in project freeplane by freeplane.

the class MapView method paintConnectors.

private void paintConnectors(final NodeView source, final Graphics2D graphics, final HashSet<ConnectorModel> alreadyPaintedConnectors) {
    final LinkController linkController = LinkController.getController(getModeController());
    final NodeModel node = source.getModel();
    final Collection<NodeLinkModel> outLinks = linkController.getLinksFrom(node);
    paintConnectors(outLinks, graphics, alreadyPaintedConnectors);
    final Collection<NodeLinkModel> inLinks = linkController.getLinksTo(node);
    paintConnectors(inLinks, graphics, alreadyPaintedConnectors);
    final int nodeViewCount = source.getComponentCount();
    for (int i = 0; i < nodeViewCount; i++) {
        final Component component = source.getComponent(i);
        if (!(component instanceof NodeView)) {
            continue;
        }
        final NodeView child = (NodeView) component;
        if (!isPrinting) {
            if (!child.isHierarchyVisible())
                continue;
            final Rectangle bounds = SwingUtilities.convertRectangle(source, child.getBounds(), this);
            final JViewport vp = (JViewport) getParent();
            final Rectangle viewRect = vp.getViewRect();
            viewRect.x -= viewRect.width;
            viewRect.y -= viewRect.height;
            viewRect.width *= 3;
            viewRect.height *= 3;
            if (!viewRect.intersects(bounds)) {
                continue;
            }
        }
        paintConnectors(child, graphics, alreadyPaintedConnectors);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) JViewport(javax.swing.JViewport) LinkController(org.freeplane.features.link.LinkController) Rectangle(java.awt.Rectangle) Component(java.awt.Component) ScalableComponent(org.freeplane.view.swing.features.filepreview.ScalableComponent) JComponent(javax.swing.JComponent) INodeView(org.freeplane.features.map.INodeView) NodeLinkModel(org.freeplane.features.link.NodeLinkModel) Point(java.awt.Point)

Example 2 with NodeLinkModel

use of org.freeplane.features.link.NodeLinkModel in project freeplane by freeplane.

the class ConnectorInListProxy method getConnectorSet.

List<NodeLinkModel> getConnectorSet() {
    final MapLinks allLinks = MapLinks.getLinks(node.getMap());
    final Set<NodeLinkModel> links = allLinks == null ? null : allLinks.get(node.getID());
    return links == null ? Collections.<NodeLinkModel>emptyList() : Collections.unmodifiableList(new ArrayList<NodeLinkModel>(links));
}
Also used : ArrayList(java.util.ArrayList) MapLinks(org.freeplane.features.link.MapLinks) NodeLinkModel(org.freeplane.features.link.NodeLinkModel)

Example 3 with NodeLinkModel

use of org.freeplane.features.link.NodeLinkModel in project freeplane by freeplane.

the class MapView method paintConnectors.

private void paintConnectors(final Collection<NodeLinkModel> links, final Graphics2D graphics, final HashSet<ConnectorModel> alreadyPaintedLinks) {
    final Font font = graphics.getFont();
    try {
        final Iterator<NodeLinkModel> linkIterator = links.iterator();
        while (linkIterator.hasNext()) {
            final NodeLinkModel next = linkIterator.next();
            if (!(next instanceof ConnectorModel)) {
                continue;
            }
            final ConnectorModel ref = (ConnectorModel) next;
            if (alreadyPaintedLinks.add(ref)) {
                final NodeModel target = ref.getTarget();
                if (target == null) {
                    continue;
                }
                final NodeModel source = ref.getSource();
                final NodeView sourceView = getNodeView(source);
                final NodeView targetView = getNodeView(target);
                final ILinkView arrowLink;
                final boolean areBothNodesVisible = sourceView != null && targetView != null && source.hasVisibleContent() && target.hasVisibleContent();
                final boolean showConnector = SHOW_CONNECTOR_LINES == showConnectors || HIDE_CONNECTOR_LINES == showConnectors || SHOW_CONNECTORS_FOR_SELECTION == showConnectors && (sourceView != null && sourceView.isSelected() || targetView != null && targetView.isSelected());
                if (showConnector) {
                    if (areBothNodesVisible && (Shape.EDGE_LIKE.equals(ref.getShape()) || sourceView.getMap().getLayoutType() == MapViewLayout.OUTLINE))
                        arrowLink = new EdgeLinkView(ref, getModeController(), sourceView, targetView);
                    else if (areBothNodesVisible || !hideSingleEndConnectors)
                        arrowLink = new ConnectorView(ref, sourceView, targetView, getBackground());
                    else
                        break;
                    arrowLink.paint(graphics);
                    arrowLinkViews.add(arrowLink);
                }
            }
        }
    } finally {
        graphics.setFont(font);
    }
}
Also used : EdgeLinkView(org.freeplane.view.swing.map.link.EdgeLinkView) NodeModel(org.freeplane.features.map.NodeModel) ILinkView(org.freeplane.view.swing.map.link.ILinkView) ConnectorView(org.freeplane.view.swing.map.link.ConnectorView) ConnectorModel(org.freeplane.features.link.ConnectorModel) INodeView(org.freeplane.features.map.INodeView) Font(java.awt.Font) NodeLinkModel(org.freeplane.features.link.NodeLinkModel)

Aggregations

NodeLinkModel (org.freeplane.features.link.NodeLinkModel)3 INodeView (org.freeplane.features.map.INodeView)2 NodeModel (org.freeplane.features.map.NodeModel)2 Component (java.awt.Component)1 Font (java.awt.Font)1 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 ArrayList (java.util.ArrayList)1 JComponent (javax.swing.JComponent)1 JViewport (javax.swing.JViewport)1 ConnectorModel (org.freeplane.features.link.ConnectorModel)1 LinkController (org.freeplane.features.link.LinkController)1 MapLinks (org.freeplane.features.link.MapLinks)1 ScalableComponent (org.freeplane.view.swing.features.filepreview.ScalableComponent)1 ConnectorView (org.freeplane.view.swing.map.link.ConnectorView)1 EdgeLinkView (org.freeplane.view.swing.map.link.EdgeLinkView)1 ILinkView (org.freeplane.view.swing.map.link.ILinkView)1