Search in sources :

Example 1 with AutomaticEdgeStyle

use of org.freeplane.view.swing.map.edge.AutomaticEdgeStyle in project freeplane by freeplane.

the class NodeView method getEdgeColor.

public Color getEdgeColor() {
    if (edgeColor.hasValue())
        return edgeColor.getValue();
    Rules rule = edgeColor.getRule();
    if (rule == EdgeController.Rules.BY_COLUMN) {
        final Color color = new AutomaticEdgeStyle(this).getColor();
        edgeColor.setCache(color);
        return color;
    }
    final NodeModel parentNode = model.getParentNode();
    if (rule == EdgeController.Rules.BY_BRANCH && parentNode.isRoot() || rule == EdgeController.Rules.BY_LEVEL) {
        final int index;
        if (rule == EdgeController.Rules.BY_BRANCH)
            index = parentNode.getIndex(model) + 1;
        else
            index = model.getNodeLevel(false) + (model.isHiddenSummary() ? 1 : 0);
        final MapModel mapModel = map.getModel();
        ModeController modeController = map.getModeController();
        EdgeController edgeController = modeController.getExtension(EdgeController.class);
        if (edgeController.areEdgeColorsAvailable(mapModel)) {
            Color color = edgeController.getEdgeColor(mapModel, index);
            edgeColor.setCache(color);
            return color;
        }
    } else if (rule == EdgeController.Rules.BY_PARENT) {
        final NodeView parentView = getParentView();
        if (parentView != null) {
            final Color color = parentView.getEdgeColor();
            return color;
        }
    }
    return Color.GRAY;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) AutomaticEdgeStyle(org.freeplane.view.swing.map.edge.AutomaticEdgeStyle) EdgeController(org.freeplane.features.edge.EdgeController) Color(java.awt.Color) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController) INodeView(org.freeplane.features.map.INodeView) Rules(org.freeplane.features.edge.EdgeController.Rules) Point(java.awt.Point)

Aggregations

Color (java.awt.Color)1 Point (java.awt.Point)1 EdgeController (org.freeplane.features.edge.EdgeController)1 Rules (org.freeplane.features.edge.EdgeController.Rules)1 INodeView (org.freeplane.features.map.INodeView)1 MapModel (org.freeplane.features.map.MapModel)1 NodeModel (org.freeplane.features.map.NodeModel)1 ModeController (org.freeplane.features.mode.ModeController)1 AutomaticEdgeStyle (org.freeplane.view.swing.map.edge.AutomaticEdgeStyle)1