Search in sources :

Example 41 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class NodeView method getCoordinates.

private void getCoordinates(final LinkedList<Point> inList, int additionalDistanceForConvexHull, final boolean byChildren, final int transX, final int transY) {
    if (!isVisible()) {
        return;
    }
    if (isContentVisible()) {
        if (byChildren) {
            final ModeController modeController = getMap().getModeController();
            final CloudController cloudController = CloudController.getController(modeController);
            final CloudModel cloud = cloudController.getCloud(getModel());
            if (cloud != null) {
                additionalDistanceForConvexHull += CloudView.getAdditionalHeigth(cloud, this) / 5;
            }
        }
        final int x = transX + getContent().getX() - getDeltaX();
        final int y = transY + getContent().getY() - getDeltaY();
        final int width = mainView.getMainViewWidthWithFoldingMark();
        final int heightWithFoldingMark = mainView.getMainViewHeightWithFoldingMark();
        final int height = Math.max(heightWithFoldingMark, getContent().getHeight());
        inList.addLast(new Point(-additionalDistanceForConvexHull + x, -additionalDistanceForConvexHull + y));
        inList.addLast(new Point(-additionalDistanceForConvexHull + x, additionalDistanceForConvexHull + y + height));
        inList.addLast(new Point(additionalDistanceForConvexHull + x + width, additionalDistanceForConvexHull + y + height));
        inList.addLast(new Point(additionalDistanceForConvexHull + x + width, -additionalDistanceForConvexHull + y));
    }
    for (final NodeView child : getChildrenViews()) {
        child.getCoordinates(inList, additionalDistanceForConvexHull, true, transX + child.getX(), transY + child.getY());
    }
}
Also used : CloudController(org.freeplane.features.cloud.CloudController) ModeController(org.freeplane.features.mode.ModeController) Point(java.awt.Point) CloudModel(org.freeplane.features.cloud.CloudModel) INodeView(org.freeplane.features.map.INodeView) Point(java.awt.Point)

Example 42 with ModeController

use of org.freeplane.features.mode.ModeController 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)

Example 43 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class NodeViewFactory method newMainView.

MainView newMainView(final NodeView node) {
    ShapeConfigurationModel shapeConfiguration = shapeConfiguration(node);
    final MainView oldView = node.getMainView();
    if (oldView != null && oldView.getShapeConfiguration().equals(shapeConfiguration))
        return oldView;
    final ModeController modeController = node.getMap().getModeController();
    final MainView view;
    switch(shapeConfiguration.getShape()) {
        case fork:
            view = new ForkMainView();
            break;
        case bubble:
            view = new BubbleMainView(shapeConfiguration);
            break;
        case oval:
            view = new OvalMainView(shapeConfiguration);
            break;
        case rectangle:
            view = new RectangleMainView(shapeConfiguration);
            break;
        case wide_hexagon:
            view = new WideHexagonMainView(shapeConfiguration);
            break;
        case narrow_hexagon:
            view = new NarrowHexagonMainView(shapeConfiguration);
            break;
        default:
            System.err.println("Tried to create a NodeView of unknown Style " + String.valueOf(shapeConfiguration.getShape()));
            view = new ForkMainView();
    }
    NodeTooltipManager toolTipManager = NodeTooltipManager.getSharedInstance(modeController);
    toolTipManager.registerComponent(view);
    return view;
}
Also used : ShapeConfigurationModel(org.freeplane.features.nodestyle.ShapeConfigurationModel) ModeController(org.freeplane.features.mode.ModeController)

Example 44 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class NodeViewFactory method shapeConfiguration.

private ShapeConfigurationModel shapeConfiguration(NodeView node) {
    final ModeController modeController = node.getMap().getModeController();
    final NodeModel model = node.getModel();
    ShapeConfigurationModel shapeConfiguration = NodeStyleController.getController(modeController).getShapeConfiguration(model);
    if (shapeConfiguration.getShape().equals(NodeStyleModel.Shape.combined)) {
        if (node.isFolded()) {
            shapeConfiguration = shapeConfiguration.withShape(NodeStyleModel.Shape.bubble);
        } else {
            shapeConfiguration = ShapeConfigurationModel.FORK;
        }
    } else
        while (shapeConfiguration.getShape().equals(NodeStyleModel.Shape.as_parent)) {
            NodeView parent = node.getParentView();
            if (parent == null)
                shapeConfiguration = ShapeConfigurationModel.DEFAULT_ROOT_OVAL;
            else if (parent.getParentView() == null)
                shapeConfiguration = ShapeConfigurationModel.FORK;
            else
                shapeConfiguration = parent.getMainView().getShapeConfiguration();
        }
    return shapeConfiguration;
}
Also used : ShapeConfigurationModel(org.freeplane.features.nodestyle.ShapeConfigurationModel) NodeModel(org.freeplane.features.map.NodeModel) ModeController(org.freeplane.features.mode.ModeController)

Example 45 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class TimeManagement method createDateFormatChooser.

private JComboBox createDateFormatChooser() {
    class DateFormatComboBoxElement {

        private final PatternFormat dateFormat;

        DateFormatComboBoxElement(PatternFormat dateFormat) {
            this.dateFormat = dateFormat;
        }

        PatternFormat getDateFormat() {
            return dateFormat;
        }

        public String toString() {
            return dateFormat.formatObject(getCalendarDate()).toString();
        }
    }
    final String dateFormatPattern = ResourceController.getResourceController().getProperty("date_format");
    final Vector<DateFormatComboBoxElement> values = new Vector<DateFormatComboBoxElement>();
    final List<PatternFormat> datePatterns = FormatController.getController().getDateFormats();
    int selectedIndex = 0;
    for (int i = 0; i < datePatterns.size(); ++i) {
        final PatternFormat patternFormat = datePatterns.get(i);
        values.add(new DateFormatComboBoxElement(patternFormat));
        if (patternFormat.getPattern().equals(dateFormatPattern)) {
            selectedIndex = i;
        }
    }
    if (!datePatterns.isEmpty()) {
        dateFormat = datePatterns.get(selectedIndex);
    }
    final JComboBox dateFormatChooser = new JComboBoxWithBorder(values);
    dateFormatChooser.setFocusable(false);
    if (!datePatterns.isEmpty()) {
        dateFormatChooser.setSelectedIndex(selectedIndex);
    }
    dateFormatChooser.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            dateFormat = ((DateFormatComboBoxElement) e.getItem()).getDateFormat();
            final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
            if (focusOwner instanceof JTable) {
                JTable table = (JTable) focusOwner;
                final int[] selectedRows = table.getSelectedRows();
                final int[] selectedColumns = table.getSelectedColumns();
                for (int r : selectedRows) for (int c : selectedColumns) {
                    Object date = table.getValueAt(r, c);
                    if (date instanceof FormattedDate) {
                        final FormattedDate fd = (FormattedDate) date;
                        if (!fd.getDateFormat().equals(dateFormat)) {
                            table.setValueAt(new FormattedDate(fd, dateFormat.getPattern()), r, c);
                        }
                    }
                }
            } else {
                ModeController mController = Controller.getCurrentModeController();
                for (final NodeModel node : mController.getMapController().getSelectedNodes()) {
                    final MTextController textController = (MTextController) TextController.getController();
                    Object date = node.getUserObject();
                    if (date instanceof FormattedDate) {
                        final FormattedDate fd = (FormattedDate) date;
                        if (!fd.getDateFormat().equals(dateFormat)) {
                            textController.setNodeObject(node, new FormattedDate(fd, dateFormat.getPattern()));
                        }
                    }
                }
            }
        }
    });
    dateFormatChooser.setAlignmentX(Component.LEFT_ALIGNMENT);
    return dateFormatChooser;
}
Also used : ItemEvent(java.awt.event.ItemEvent) JComboBox(javax.swing.JComboBox) PatternFormat(org.freeplane.features.format.PatternFormat) ModeController(org.freeplane.features.mode.ModeController) FormattedDate(org.freeplane.features.format.FormattedDate) NodeModel(org.freeplane.features.map.NodeModel) JTable(javax.swing.JTable) ItemListener(java.awt.event.ItemListener) MTextController(org.freeplane.features.text.mindmapmode.MTextController) JComboBoxWithBorder(org.freeplane.core.ui.components.JComboBoxWithBorder) Component(java.awt.Component) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent) Vector(java.util.Vector)

Aggregations

ModeController (org.freeplane.features.mode.ModeController)185 NodeModel (org.freeplane.features.map.NodeModel)80 Controller (org.freeplane.features.mode.Controller)43 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)36 MapController (org.freeplane.features.map.MapController)31 MapModel (org.freeplane.features.map.MapModel)30 IActor (org.freeplane.core.undo.IActor)28 ResourceController (org.freeplane.core.resources.ResourceController)21 MMapController (org.freeplane.features.map.mindmapmode.MMapController)21 Point (java.awt.Point)16 TextController (org.freeplane.features.text.TextController)16 Component (java.awt.Component)13 MapView (org.freeplane.view.swing.map.MapView)13 LinkController (org.freeplane.features.link.LinkController)12 NodeView (org.freeplane.view.swing.map.NodeView)12 Color (java.awt.Color)11 File (java.io.File)11 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)11 IMapSelection (org.freeplane.features.map.IMapSelection)10 ViewController (org.freeplane.features.ui.ViewController)10