Package org.freeplane.features.text.mindmapmode

Examples of org.freeplane.features.text.mindmapmode.MTextController


    removeFormattingAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control T"));
   
    inputMethodInUseListener = new InputMethodInUseListener();
    if(editControl != null ){
      final ModeController modeController = Controller.getCurrentModeController();
      final MTextController textController = (MTextController) TextController.getController(modeController);
      textfield = textController.createEditorPane(MTextController.NODE_TEXT);
      textfield.setNavigationFilter(new MyNavigationFilter(textfield));
      textfield.addInputMethodListener(inputMethodInUseListener);
    }
  }
View Full Code Here


  @SuppressWarnings("serial")
    @Override
  public void show(final RootPaneContainer frame) {
    final ModeController modeController = Controller.getCurrentModeController();
    final IMapViewManager viewController = modeController.getController().getMapViewManager();
    final MTextController textController = (MTextController) TextController.getController(modeController);
    nodeView = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, parent);
    font = parent.getFont();
    zoom = viewController.getZoom();
    if (zoom != 1F) {
      final float fontSize = (int) (Math.rint(font.getSize() * zoom));
      font = font.deriveFont(fontSize);
    }
    final HTMLEditorKit kit = new ScaledEditorKit(){
      @Override
      public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException {
        if (doc instanceof HTMLDocument) {
          HTMLWriter w = new SHTMLWriter(out, (HTMLDocument) doc, pos, len);
          w.write();
        }
        else {
          super.write(out, doc, pos, len);
        }
      }
    };
    textfield.setEditorKit(kit);

    final InputMap inputMap = textfield.getInputMap();
    final ActionMap actionMap = textfield.getActionMap();
    actionMap.put(DefaultEditorKit.pasteAction, pasteAction);
   
    inputMap.put((KeyStroke) boldAction.getValue(Action.ACCELERATOR_KEY), "boldAction");
    actionMap.put("boldAction",boldAction);
   
    inputMap.put((KeyStroke) italicAction.getValue(Action.ACCELERATOR_KEY), "italicAction");
    actionMap.put("italicAction", italicAction);
   
    inputMap.put((KeyStroke) underlineAction.getValue(Action.ACCELERATOR_KEY), "underlineAction");
    actionMap.put("underlineAction", underlineAction);
   
    inputMap.put((KeyStroke) redAction.getValue(Action.ACCELERATOR_KEY), "redAction");
    actionMap.put("redAction", redAction);
   
    inputMap.put((KeyStroke) greenAction.getValue(Action.ACCELERATOR_KEY), "greenAction");
    actionMap.put("greenAction", greenAction);
   
    inputMap.put((KeyStroke) blueAction.getValue(Action.ACCELERATOR_KEY), "blueAction");
    actionMap.put("blueAction", blueAction);
   
    inputMap.put((KeyStroke) blackAction.getValue(Action.ACCELERATOR_KEY), "blackAction");
    actionMap.put("blackAction", blackAction);
   
    inputMap.put((KeyStroke) defaultColorAction.getValue(Action.ACCELERATOR_KEY), "defaultColorAction");
    actionMap.put("defaultColorAction", defaultColorAction);
   
    inputMap.put((KeyStroke) removeFormattingAction.getValue(Action.ACCELERATOR_KEY), "removeFormattingAction");
    actionMap.put("removeFormattingAction", removeFormattingAction);
   
    final Color nodeTextColor = parent.getForeground();
    textfield.setCaretColor(nodeTextColor);
    final StringBuilder ruleBuilder = new StringBuilder(100);
    ruleBuilder.append("body {");
    ruleBuilder.append("font-family: ").append(font.getFamily()).append(";");
    final int fontSize = Math.round(font.getSize() / UITools.FONT_SCALE_FACTOR);
    ruleBuilder.append("font-size: ").append(fontSize).append("pt;");
    if (font.isItalic()) {
      ruleBuilder.append("font-style: italic; ");
    }
    if (font.isBold()) {
      ruleBuilder.append("font-weight: bold; ");
    }
    ruleBuilder.append("color: ").append(ColorUtils.colorToString(nodeTextColor)).append(";");
      final Color bgColor = getBackground();
    ruleBuilder.append("background-color: ").append(ColorUtils.colorToString(bgColor)).append(";");
    ruleBuilder.append("}\n");
    final HTMLDocument document = (HTMLDocument) textfield.getDocument();
    final StyleSheet styleSheet = document.getStyleSheet();
    styleSheet.addRule(ruleBuilder.toString());
    textfield.setText(text);
    final MapView mapView = (MapView) viewController.getMapViewComponent();
    if(! mapView.isValid())
      mapView.validate();
    final NodeStyleController nsc = NodeStyleController.getController(modeController);
    maxWidth = nsc.getMaxWidth(node);
    final Icon icon = parent.getIcon();
    if(icon != null){
      maxWidth -= icon.getIconWidth();
      maxWidth -= parent.getIconTextGap();
    }
    maxWidth = mapView.getZoomed(maxWidth);
    extraWidth = ResourceController.getResourceController().getIntProperty("editor_extra_width", 80);
    extraWidth = mapView.getZoomed(extraWidth);
    final TextFieldListener textFieldListener = new TextFieldListener();
    this.textFieldListener = textFieldListener;
    textfield.addFocusListener(textFieldListener);
    textfield.addKeyListener(textFieldListener);
    textfield.addMouseListener(textFieldListener);
    mapViewChangeListener = new MapViewChangeListener();
    Controller.getCurrentController().getMapViewManager().addMapViewChangeListener(mapViewChangeListener);
    SpellCheckerController.getController().enableAutoSpell(textfield, true);
    mapView.scrollNodeToVisible(nodeView);
    assert( parent.isValid());
    final int nodeWidth = parent.getWidth();
    final int nodeHeight = parent.getHeight();
    final Dimension textFieldSize;
    textfield.setBorder(new MatteBorder(2, 2, 2, 2, nodeView.getSelectedColor()));
    textFieldSize = textfield.getPreferredSize();
    textFieldSize.width += 1;
        if(textFieldSize.width < extraWidth)
            textFieldSize.width = extraWidth;
        if(textFieldSize.width < 10)
            textFieldSize.width = 10;
    if (textFieldSize.width > maxWidth) {
      textFieldSize.width = maxWidth;
      setLineWrap();
      textFieldSize.height = textfield.getPreferredSize().height;
    }
    final Rectangle textR = ((ZoomableLabelUI)parent.getUI()).getTextR(parent);
    textFieldSize.width = Math.max(textFieldSize.width, textR.width);
    textFieldSize.height = Math.max(textFieldSize.height, textR.height);
    textfield.setSize(textFieldSize.width, textFieldSize.height);
    horizontalSpace = Math.max(nodeWidth - textFieldSize.width, textR.x);
    verticalSpace = Math.max(nodeHeight - textFieldSize.height, textR.y);
    final Dimension newParentSize = new Dimension(horizontalSpace + textFieldSize.width, verticalSpace + textFieldSize.height);
    parent.setPreferredSize(newParentSize);

    final Point location = new Point(textR.x - 2, textR.y);
    if(! layoutMapOnTextChange)
      UITools.convertPointToAncestor(parent, location, mapView);
    textfield.setBounds(location.x, location.y, textFieldSize.width, textFieldSize.height);
    parent.setText("");
        if(nodeView.isRoot() && parent instanceof MainView)
            parent.setHorizontalAlignment(JLabel.LEFT);
    if(layoutMapOnTextChange)
      parent.add(textfield, 0);
    else
      mapView.add(textfield, 0);
    final EventBuffer eventQueue = MTextController.getController().getEventQueue();
    KeyEvent firstEvent = eventQueue.getFirstEvent();
    redispatchKeyEvents(textfield, firstEvent);
    if (firstEvent == null) {
      MouseEvent currentEvent = eventQueue.getMouseEvent();
      int pos = document.getLength();
      if(currentEvent != null){
        MouseEvent mouseEvent = (MouseEvent) currentEvent;
        if(mouseEvent.getComponent().equals(parent)){
          final Point point = mouseEvent.getPoint();
          point.x -= textR.x;
          point.y -= textR.y;
          pos = textfield.viewToModel(point);
        }
      }
      textfield.setCaretPosition(pos);
    }
    document.addDocumentListener(documentListener);
    if(textController.isMinimized(node)){
      layout();
    }
    textfield.repaint();
    textfield.requestFocusInWindow();
  }
View Full Code Here

          return;
        }
      }
      else {
        if (Compat.isPlainEvent(e) && !isInFoldingRegion(e)) {
          final MTextController textController = MTextController.getController();
          textController.getEventQueue().activate(e);
          textController.edit(FirstAction.EDIT_CURRENT, false);
        }
      }
    }
    super.mouseClicked(e);
  }
View Full Code Here

    final MapController mapController = modeController.getMapController();
    EdgeController.install(new MEdgeController(modeController));
    CloudController.install(new MCloudController(modeController));
    NoteController.install(new MNoteController(modeController));
    userInputListenerFactory.setMapMouseListener(new MMapMouseListener());
    final MTextController textController = new MTextController(modeController);
    TextController.install(textController);
    LinkController.install(new MLinkController());
    NodeStyleController.install(new MNodeStyleController(modeController));
    ClipboardController.install(new MClipboardController());
    userInputListenerFactory.setNodeDragListener(new MNodeDragListener());
    userInputListenerFactory.setNodeDropTargetListener(new MNodeDropListener());
    LocationController.install(new MLocationController());
    final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
    LogicalStyleController.install(logicalStyleController);
    logicalStyleController.initM();
    AttributeController.install(new MAttributeController(modeController));
    userInputListenerFactory.setNodeKeyListener(new DefaultNodeKeyListener(new IEditHandler() {
      public void edit(final KeyEvent e, final FirstAction action, final boolean editLong) {
        ((MTextController) MTextController.getController(modeController)).getEventQueue().activate(e);
        textController.edit(action, editLong);
      }
    }));
    userInputListenerFactory.setNodeMotionListener(new MNodeMotionListener());
    modeController.addAction(new EditAttributesAction());
    SpellCheckerController.install(modeController);
View Full Code Here

    setDetailsText(convertConvertibleToHtml(details));
  }

  // Node: R/W
    public void setDetailsText(String html) {
        final MTextController textController = (MTextController) TextController.getController();
    if (html == null) {
      textController.setDetailsHidden(getDelegate(), false);
      textController.setDetails(getDelegate(), null);
    }
    else{
      textController.setDetails(getDelegate(), html);
    }
    }
View Full Code Here

    }
    }
 
  // Node: R/W
  public void setHideDetails(boolean hide) {
    MTextController controller = (MTextController) MTextController.getController();
    controller.setDetailsHidden(getDelegate(), hide);
    }
View Full Code Here

            freeNode.undoableToggleHook(getDelegate());
    }
 
  // Node: R/W
  public void setMinimized(boolean shortened){
    final MTextController textController = (MTextController) TextController.getController();
    textController.setIsMinimized(getDelegate(), shortened);
  }
View Full Code Here

  }

  // Node: R/W
  public void setText(final Object value) {
    if (value instanceof String) {
      final MTextController textController = (MTextController) TextController.getController();
      textController.setNodeText(getDelegate(), (String) value);
    }
    else {
      setObject(value);
    }
  }
View Full Code Here

    }
  }
 
  // Node: R/W
  public void setObject(final Object object) {
    final MTextController textController = (MTextController) TextController.getController();
    textController.setNodeObject(getDelegate(), ProxyUtils.transformObject(object, null));
  }
View Full Code Here

    textController.setNodeObject(getDelegate(), ProxyUtils.transformObject(object, null));
  }

  // Node: R/W
  public void setDateTime(final Date date) {
    final MTextController textController = (MTextController) TextController.getController();
    textController.setNodeObject(getDelegate(), ProxyUtils.createDefaultFormattedDateTime(date));
  }
View Full Code Here

TOP

Related Classes of org.freeplane.features.text.mindmapmode.MTextController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.