Search in sources :

Example 71 with ModeController

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

the class TimeManagement method insertTime.

void insertTime(final Dialog dialog, final JButton appendButton) {
    FormattedDate date = getCalendarDate();
    final String dateAsString = dateFormat.formatObject(date).toString();
    final Window parentWindow;
    if (dialog != null) {
        parentWindow = (Window) dialog.getParent();
    } else {
        parentWindow = SwingUtilities.getWindowAncestor(appendButton);
    }
    final Component mostRecentFocusOwner = parentWindow.getMostRecentFocusOwner();
    if (mostRecentFocusOwner instanceof JTextComponent && !(mostRecentFocusOwner.getClass().getName().contains("JSpinField"))) {
        final JTextComponent textComponent = (JTextComponent) mostRecentFocusOwner;
        textComponent.replaceSelection(dateAsString);
        return;
    }
    if (mostRecentFocusOwner instanceof JTable) {
        JTable table = (JTable) mostRecentFocusOwner;
        final int[] selectedRows = table.getSelectedRows();
        final int[] selectedColumns = table.getSelectedColumns();
        for (int r : selectedRows) for (int c : selectedColumns) table.setValueAt(date, r, c);
    } else {
        ModeController mController = Controller.getCurrentModeController();
        for (final NodeModel node : mController.getMapController().getSelectedNodes()) {
            final MTextController textController = (MTextController) TextController.getController();
            textController.setNodeObject(node, date);
        }
    }
}
Also used : Window(java.awt.Window) FormattedDate(org.freeplane.features.format.FormattedDate) NodeModel(org.freeplane.features.map.NodeModel) JTable(javax.swing.JTable) JTextComponent(javax.swing.text.JTextComponent) ModeController(org.freeplane.features.mode.ModeController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) Component(java.awt.Component) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent)

Example 72 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)) {
            dateFormat = patternFormat;
            selectedIndex = i;
        }
    }
    final JComboBox dateFormatChooser = new JComboBox(values);
    dateFormatChooser.setFocusable(false);
    if (!datePatterns.isEmpty()) {
        dateFormatChooser.setSelectedIndex(selectedIndex);
        dateFormat = ((DateFormatComboBoxElement) (dateFormatChooser.getSelectedItem())).getDateFormat();
    }
    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) Component(java.awt.Component) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent) Vector(java.util.Vector)

Example 73 with ModeController

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

the class MainView method updateIcons.

void updateIcons(final NodeView node) {
    // setHorizontalTextPosition(node.isLeft() ? SwingConstants.LEADING : SwingConstants.TRAILING);
    final MultipleImage iconImages = new MultipleImage();
    /* fc, 06.10.2003: images? */
    final NodeModel model = node.getModel();
    for (final UIIcon icon : IconController.getController().getStateIcons(model)) {
        iconImages.addImage(icon.getIcon());
    }
    final ModeController modeController = getNodeView().getMap().getModeController();
    final Collection<MindIcon> icons = IconController.getController(modeController).getIcons(model);
    for (final MindIcon myIcon : icons) {
        iconImages.addImage(myIcon.getIcon());
    }
    addOwnIcons(iconImages, model);
    setIcon((iconImages.getImageCount() > 0 ? iconImages : null));
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MultipleImage(org.freeplane.core.ui.components.MultipleImage) MindIcon(org.freeplane.features.icon.MindIcon) ModeController(org.freeplane.features.mode.ModeController) UIIcon(org.freeplane.features.icon.UIIcon)

Example 74 with ModeController

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

the class BubbleMainView method paintComponent.

@Override
public void paintComponent(final Graphics graphics) {
    final Graphics2D g = (Graphics2D) graphics;
    final NodeView nodeView = getNodeView();
    final NodeModel model = nodeView.getModel();
    if (model == null) {
        return;
    }
    final ModeController modeController = getNodeView().getMap().getModeController();
    final Object renderingHint = modeController.getController().getMapViewManager().setEdgesRenderingHint(g);
    paintBackgound(g);
    paintDragOver(g);
    final Color edgeColor = nodeView.getEdgeColor();
    g.setColor(edgeColor);
    g.setStroke(BubbleMainView.DEF_STROKE);
    g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 10, 10);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, renderingHint);
    super.paintComponent(g);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) Color(java.awt.Color) ModeController(org.freeplane.features.mode.ModeController) Graphics2D(java.awt.Graphics2D)

Example 75 with ModeController

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

the class ArrowIcon method paintIcon.

public void paintIcon(Component c, Graphics g, int x, int y) {
    int[] xs = new int[3];
    int[] ys = new int[3];
    xs[0] = 1 + ARROW_HALF_WIDTH;
    xs[1] = 1;
    xs[2] = xs[0] + ARROW_HALF_WIDTH;
    if (down) {
        ys[0] = 1 + ARROW_HEIGTH;
        ys[1] = ys[2] = 1;
    } else {
        ys[0] = 1;
        ys[1] = ys[2] = 1 + ARROW_HEIGTH;
    }
    final Color oldColor = g.getColor();
    final Color color = nodeView.getEdgeColor();
    g.setColor(color);
    Graphics2D g2 = (Graphics2D) g;
    final Object renderingHint = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    ModeController modeController = this.nodeView.getMap().getModeController();
    modeController.getController().getMapViewManager().setEdgesRenderingHint(g2);
    g.drawPolygon(xs, ys, 3);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, renderingHint);
    g.setColor(oldColor);
}
Also used : Color(java.awt.Color) ModeController(org.freeplane.features.mode.ModeController) Graphics2D(java.awt.Graphics2D)

Aggregations

ModeController (org.freeplane.features.mode.ModeController)222 NodeModel (org.freeplane.features.map.NodeModel)90 Controller (org.freeplane.features.mode.Controller)56 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)48 MapModel (org.freeplane.features.map.MapModel)37 IActor (org.freeplane.core.undo.IActor)31 MapController (org.freeplane.features.map.MapController)30 ResourceController (org.freeplane.core.resources.ResourceController)29 MMapController (org.freeplane.features.map.mindmapmode.MMapController)20 File (java.io.File)17 TextController (org.freeplane.features.text.TextController)17 Color (java.awt.Color)16 Point (java.awt.Point)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MapView (org.freeplane.view.swing.map.MapView)13 NodeView (org.freeplane.view.swing.map.NodeView)13 Component (java.awt.Component)12 URL (java.net.URL)12 LinkController (org.freeplane.features.link.LinkController)12 MenuBuilder (org.freeplane.core.ui.MenuBuilder)11