Package org.freeplane.view.swing.map

Examples of org.freeplane.view.swing.map.MapView


      final Point draggedLinkNewEndPoint = draggedLink.getEndInclination();
      draggedLink.setStartInclination(draggedLinkOldStartPoint);
      draggedLink.setEndInclination(draggedLinkOldEndPoint);
      ((MLinkController) LinkController.getController(Controller.getCurrentController().getModeController())).setArrowLinkEndPoints(draggedLink,
        draggedLinkNewStartPoint, draggedLinkNewEndPoint);
      final MapView mapView = (MapView) e.getComponent();
      mapView.repaintVisible();
      draggedLink = null;
    }
  }
View Full Code Here


  @Override
    public void mouseClicked(MouseEvent e) {

    if(e.getClickCount() == 2 && Compat.isCtrlEvent(e)){
      final MapView mapView = (MapView) e.getComponent();
      final Object object = mapView.detectCollision(new Point(originX, originY));
      if(object != null)
        return;
      final ModeController modeController = Controller.getCurrentModeController();
      final IExtension freeNode = modeController.getExtension(FreeNode.class);
      if(freeNode != null && modeController instanceof MModeController){
        final JComponent rootContent = mapView.getRoot().getMainView();
        final Point contentPt = new Point();
        UITools.convertPointToAncestor(rootContent, contentPt, mapView);
        final float zoom = mapView.getZoom();
        final Point eventPoint = e.getPoint();
        int x =(int) ((eventPoint.x - contentPt.x)/zoom);
        final int y =(int) ((eventPoint.y - contentPt.y)/zoom);
        final int rootContentNormalWidth = (int)(rootContent.getWidth()/zoom);
        final boolean newNodeIsLeft = x < rootContentNormalWidth/2;
View Full Code Here

*/
public class MNodeDragListener implements DragGestureListener {
  public void dragGestureRecognized(final DragGestureEvent e) {
    final MainView mainView = (MainView) e.getComponent();
    final NodeView nodeView = mainView.getNodeView();
    final MapView mapView = nodeView.getMap();
    mapView.select();
    if(! nodeView.isSelected()){
      nodeView.getMap().getModeController().getController().getSelection().selectAsTheOnlyOneSelected(nodeView.getModel());
    }
    Rectangle bounds = new Rectangle(0, 0, mainView.getWidth(), mainView.getHeight());
    if(!bounds.contains(e.getDragOrigin()))
View Full Code Here

    textfield.setSize(preferredSize);
    if(layoutMapOnTextChange)
      parent.setPreferredSize(new Dimension(preferredSize.width + horizontalSpace , preferredSize.height + verticalSpace));
    textfield.revalidate();
    final NodeView nodeView = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, parent);
    final MapView mapView = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, nodeView);
    if(mapView == null)
      return;
    if(layoutMapOnTextChange)
      mapView.scrollNodeToVisible(nodeView);
    else
      mapView.scrollRectToVisible(textfield.getBounds());
  }
View Full Code Here

      nodeView.update();
    if(nodeView.isRoot() && parent instanceof MainView)
        parent.setHorizontalAlignment(JLabel.CENTER);
    final Dimension textFieldSize = textfield.getSize();
    final Point textFieldCoordinate = new Point();
    final MapView mapView = nodeView.getMap();
    UITools.convertPointToAncestor(textfield, textFieldCoordinate, mapView);
    textfield.getParent().remove(textfield);
    parent.revalidate();
    parent.repaint();
    mapView.repaint(textFieldCoordinate.x, textFieldCoordinate.y, textFieldSize.width, textFieldSize.height);
    textfield = null;
  }
View Full Code Here

    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();
View Full Code Here

    this.editHandler = editHandler;
  }

  public void keyPressed(final KeyEvent e) {
    final boolean checkForScrollMap = e.isShiftDown() && e.isControlDown()&& e.isAltDown();
    final MapView mapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
    if (mapView == null || SwingUtilities.isDescendingFrom(mapView, e.getComponent()))
      return;
    if(checkForScrollMap){
      switch (e.getKeyCode()) {
      case KeyEvent.VK_UP:
          mapView.scrollBy(0, -10);
          e.consume();
        return;
      case KeyEvent.VK_DOWN:
          mapView.scrollBy(0, 10);
          e.consume();
        return;
      case KeyEvent.VK_LEFT:
          mapView.scrollBy(-10, 0);
          e.consume();
        return;
      case KeyEvent.VK_RIGHT:
          mapView.scrollBy(10, 0);
          e.consume();
      }
      return;
    }
    if ((e.isAltDown() || e.isControlDown() || e.isMetaDown())) {
      return;
    }
    switch (e.getKeyCode()) {
      case KeyEvent.VK_ENTER:
      case KeyEvent.VK_ESCAPE:
      case KeyEvent.VK_SHIFT:
      case KeyEvent.VK_DELETE:
      case KeyEvent.VK_SPACE:
      case KeyEvent.VK_INSERT:
      case KeyEvent.VK_TAB:
        return;
    }
    final boolean continious = e.isShiftDown();
    switch (e.getKeyCode()) {
      case KeyEvent.VK_UP:
        if (mapView.selectUp(continious))
          e.consume();
        return;
      case KeyEvent.VK_DOWN:
        if (mapView.selectDown(continious))
          e.consume();
        return;
      case KeyEvent.VK_LEFT:
        if (mapView.selectLeft(continious))
          e.consume();
        return;
      case KeyEvent.VK_RIGHT:
        if (mapView.selectRight(continious))
          e.consume();
        return;
      case KeyEvent.VK_PAGE_UP:
        if (mapView.selectPageUp(continious))
          e.consume();
        return;
      case KeyEvent.VK_PAGE_DOWN:
        if (mapView.selectPageDown(continious))
          e.consume();
        return;
      case KeyEvent.VK_HOME:
      case KeyEvent.VK_END:
      case KeyEvent.VK_BACK_SPACE:
        if (editHandler != null) {
          editHandler.edit(e, FirstAction.EDIT_CURRENT, false);
        }
        return;
      case KeyEvent.VK_CONTEXT_MENU:
        final ModeController modeController = Controller.getCurrentModeController();
        final NodeModel node = Controller.getCurrentModeController().getMapController().getSelectedNode();
        final NodeView nodeView = mapView.getNodeView(node);
        final JPopupMenu popupmenu = modeController.getUserInputListenerFactory().getNodePopupMenu();
        if (popupmenu != null) {
          popupmenu.addHierarchyListener(new ControllerPopupMenuListener());
          final MainView mainView = nodeView.getMainView();
          popupmenu.show(mainView, mainView.getX(), mainView.getY());
View Full Code Here

  public void setTitle() {
    if(loadingLayoutFromObjectInpusStream)
      return;
    for (Component mapViewComponent: mapViews) {
      if (mapViewComponent instanceof MapView ) {
              MapView mapView = (MapView)mapViewComponent;
              String name = mapView.getName();
              String title;
              if(mapView.getModel().isSaved())
                title = name;
              else
                title = name + " *";
              View containingDockedWindow = getContainingDockedWindow(mapViewComponent);
        containingDockedWindow.getViewProperties().setTitle(title);
View Full Code Here

                }
                MenuUtils.executeMenuItems(options.getMenuItemsToExecute());
            }

      private void focusCurrentView() {
        final MapView currentMapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
        if(currentMapView != null){
          viewController.focusTo(currentMapView);
        }
            }
    });
View Full Code Here

  public void writeView(View view, ObjectOutputStream out) throws IOException {
      if(view.isDisplayable()) {
        Component component = MapViewDockingWindows.getContainedMapView(view);
        if (component instanceof MapView) {
          MapView mapView = (MapView) component;
          if(mapView.getModeController().getModeName().equals(MModeController.MODENAME)
              && ! mapView.getModel().containsExtension(DocuMapAttribute.class)){
            out.writeBoolean(true);
            out.writeUTF(mapView.getModeController().getModeName());
            out.writeObject(mapView.getModel().getURL());
            return;
          }
            }
      }
      out.writeBoolean(false);
View Full Code Here

TOP

Related Classes of org.freeplane.view.swing.map.MapView

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.