Search in sources :

Example 1 with Rules

use of org.freeplane.features.edge.EdgeController.Rules in project freeplane by freeplane.

the class NodeView method setBounds.

@Override
public void setBounds(int x, int y, int width, int height) {
    Rules rule = edgeColor.getRule();
    if (EdgeController.Rules.BY_PARENT != rule)
        edgeColor.resetCache();
    super.setBounds(x, y, width, height);
}
Also used : Rules(org.freeplane.features.edge.EdgeController.Rules)

Example 2 with Rules

use of org.freeplane.features.edge.EdgeController.Rules 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

Rules (org.freeplane.features.edge.EdgeController.Rules)2 Color (java.awt.Color)1 Point (java.awt.Point)1 EdgeController (org.freeplane.features.edge.EdgeController)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