Example #1
0
  @SuppressWarnings("serial")
  @Override
  public void init() {
    try {
      appletLock.lock();
      appletResourceController = new AppletResourceController(this);
      if (appletResourceController == null) {
        appletResourceController = new AppletResourceController(this);
      }
      new ParserDelegator() {
        {
          setDefaultDTD();
        }
      };
      updateLookAndFeel();
      createRootPane();
      controller = new Controller(appletResourceController);
      appletResourceController.init();
      Controller.setCurrentController(controller);
      final Container contentPane = getContentPane();
      contentPane.setLayout(new BorderLayout());
      MapViewController mapViewController = new MapViewController(controller);
      appletViewController = new AppletViewController(this, controller, mapViewController);
      controller.addAction(new ViewLayoutTypeAction(MapViewLayout.OUTLINE));
      FilterController.install();
      PrintController.install();
      HelpController.install();
      NodeHistory.install(controller);
      FormatController.install(new FormatController());
      ModelessAttributeController.install();
      TextController.install();
      MapController.install();

      TimeController.install();
      LinkController.install();
      IconController.install();
      FilterController.getCurrentFilterController()
          .getConditionFactory()
          .addConditionController(7, new LogicalStyleFilterController());
      final BModeController browseController = BModeControllerFactory.createModeController();
      final Set<String> emptySet = Collections.emptySet();
      FilterController.getController(controller).loadDefaultConditions();
      browseController.updateMenus("/xml/appletMenu.xml", emptySet);
      controller.addAction(new ShowSelectionAsRectangleAction());
      controller.addAction(new NextNodeAction(Direction.FORWARD));
      controller.addAction(new NextNodeAction(Direction.BACK));
      controller.addAction(new NextPresentationItemAction());
      controller.selectMode(browseController);
      appletResourceController.setPropertyByParameter(this, "browsemode_initial_map");
      appletViewController.init(controller);
      final GlassPane glassPane = new GlassPane();
      setGlassPane(glassPane);
      glassPane.setVisible(true);
      controller.getViewController().setMenubarVisible(false);
    } catch (RuntimeException e) {
      e.printStackTrace();
      throw e;
    } finally {
      appletLock.unlock();
    }
  }
Example #2
0
  public void setStyle(final NodeModel node) {
    if (internalChange) {
      return;
    }
    internalChange = true;
    try {
      final LogicalStyleController logicalStyleController = LogicalStyleController.getController();
      if (addStyleBox) {
        final boolean isStyleSet = LogicalStyleModel.getStyle(node) != null;
        mSetStyle.setValue(isStyleSet);
        setStyleList(mMapStyleButton, logicalStyleController.getMapStyleNames(node, "\n"));
      }
      setStyleList(mNodeStyleButton, logicalStyleController.getNodeStyleNames(node, "\n"));
      final NodeStyleController styleController = NodeStyleController.getController();
      {
        final Color nodeColor = NodeStyleModel.getColor(node);
        final Color viewNodeColor = styleController.getColor(node);
        mSetNodeColor.setValue(nodeColor != null);
        mNodeColor.setColorValue(viewNodeColor);
      }
      {
        final Color color = NodeStyleModel.getBackgroundColor(node);
        final Color viewColor = styleController.getBackgroundColor(node);
        mSetNodeBackgroundColor.setValue(color != null);
        mNodeBackgroundColor.setColorValue(
            viewColor != null
                ? viewColor
                : Controller.getCurrentController().getMapViewManager().getBackgroundColor(node));
      }
      {
        final String shape = NodeStyleModel.getShape(node);
        final String viewShape = styleController.getShape(node);
        mSetNodeShape.setValue(shape != null);
        mNodeShape.setValue(viewShape);
      }
      final NodeSizeModel nodeSizeModel = NodeSizeModel.getModel(node);
      {
        final int width =
            nodeSizeModel != null ? nodeSizeModel.getMaxNodeWidth() : NodeSizeModel.NOT_SET;
        final int viewWidth = styleController.getMaxWidth(node);
        mSetMaxNodeWidth.setValue(width != NodeSizeModel.NOT_SET);
        mMaxNodeWidth.setValue(Integer.toString(viewWidth));
      }
      {
        final int width =
            nodeSizeModel != null ? nodeSizeModel.getMinNodeWidth() : NodeSizeModel.NOT_SET;
        final int viewWidth = styleController.getMinWidth(node);
        mSetMinNodeWidth.setValue(width != NodeSizeModel.NOT_SET);
        mMinNodeWidth.setValue(Integer.toString(viewWidth));
      }
      final EdgeController edgeController = EdgeController.getController();
      final EdgeModel edgeModel = EdgeModel.getModel(node);
      {
        final Color edgeColor = edgeModel != null ? edgeModel.getColor() : null;
        final Color viewColor = edgeController.getColor(node);
        mSetEdgeColor.setValue(edgeColor != null);
        mEdgeColor.setColorValue(viewColor);
      }
      {
        final EdgeStyle style = edgeModel != null ? edgeModel.getStyle() : null;
        final EdgeStyle viewStyle = edgeController.getStyle(node);
        mSetEdgeStyle.setValue(style != null);
        mEdgeStyle.setValue(viewStyle.toString());
      }
      {
        final int width = edgeModel != null ? edgeModel.getWidth() : EdgeModel.DEFAULT_WIDTH;
        final int viewWidth = edgeController.getWidth(node);
        mSetEdgeWidth.setValue(width != EdgeModel.DEFAULT_WIDTH);
        mEdgeWidth.setValue(Integer.toString(viewWidth));
      }
      {
        final CloudController cloudController = CloudController.getController();
        final CloudModel cloudModel = CloudModel.getModel(node);
        final Color viewCloudColor = cloudController.getColor(node);
        mSetCloud.setValue(cloudModel != null);
        mCloudColor.setColorValue(viewCloudColor);

        final CloudModel.Shape viewCloudShape = cloudController.getShape(node);
        mCloudShape.setValue(
            viewCloudShape != null ? viewCloudShape.toString() : CloudModel.Shape.ARC.toString());
      }
      {
        final String fontFamilyName = NodeStyleModel.getFontFamilyName(node);
        final String viewFontFamilyName = styleController.getFontFamilyName(node);
        mSetNodeFontName.setValue(fontFamilyName != null);
        mNodeFontName.setValue(viewFontFamilyName);
      }
      {
        final Integer fontSize = NodeStyleModel.getFontSize(node);
        final Integer viewfontSize = styleController.getFontSize(node);
        mSetNodeFontSize.setValue(fontSize != null);
        mNodeFontSize.setValue(viewfontSize.toString());
      }
      {
        final Boolean bold = NodeStyleModel.isBold(node);
        final Boolean viewbold = styleController.isBold(node);
        mSetNodeFontBold.setValue(bold != null);
        mNodeFontBold.setValue(viewbold);
      }
      {
        final Boolean italic = NodeStyleModel.isItalic(node);
        final Boolean viewitalic = styleController.isItalic(node);
        mSetNodeFontItalic.setValue(italic != null);
        mNodeFontItalic.setValue(viewitalic);
      }
      {
        final Boolean hyperlink = NodeLinks.formatNodeAsHyperlink(node);
        final Boolean viewhyperlink = LinkController.getController().formatNodeAsHyperlink(node);
        mSetNodeFontHyperlink.setValue(hyperlink != null);
        mNodeFontHyperlink.setValue(viewhyperlink);
      }
      {
        final Boolean nodeNumbering = NodeStyleModel.getNodeNumbering(node);
        final Boolean viewNodeNumbering = styleController.getNodeNumbering(node);
        mSetNodeNumbering.setValue(nodeNumbering != null);
        mNodeNumbering.setValue(viewNodeNumbering);
      }
      {
        String nodeFormat = NodeStyleModel.getNodeFormat(node);
        String viewNodeFormat = TextController.getController().getNodeFormat(node);
        mSetNodeFormat.setValue(nodeFormat != null);
        if (viewNodeFormat == null && node.getUserObject() instanceof IFormattedObject)
          viewNodeFormat = ((IFormattedObject) node.getUserObject()).getPattern();
        mNodeFormat.setValue(viewNodeFormat);
      }
      if (mAutomaticLayoutComboBox != null) {
        final ModeController modeController = Controller.getCurrentModeController();
        AutomaticLayoutController al = modeController.getExtension(AutomaticLayoutController.class);
        IExtension extension = al.getExtension(node);
        if (extension == null) mAutomaticLayoutComboBox.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
        else mAutomaticLayoutComboBox.setSelectedIndex(((AutomaticLayout) extension).ordinal());
      }
      if (mAutomaticEdgeColorCheckBox != null) {
        final ModeController modeController = Controller.getCurrentModeController();
        AutomaticEdgeColorHook al =
            (AutomaticEdgeColorHook) modeController.getExtension(AutomaticEdgeColorHook.class);
        mAutomaticEdgeColorCheckBox.setSelected(al.isActive(node));
      }
    } finally {
      internalChange = false;
    }
  }
  public void mouseClicked(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1 && e.getSource() instanceof MainView) {
      MainView view = (MainView) e.getSource();
      Rectangle bounds = ((ZoomableLabelUI) view.getUI()).getIconR(view);
      Point p = e.getPoint();
      if (bounds.contains(p)) {
        if (view.getIcon() instanceof MultipleImage) {
          Rectangle iconR =
              ((MultipleImage) view.getIcon())
                  .getIconR(PdfUtilitiesController.REFRESH_MONITORING_ICON);
          if (iconR != null) {
            float zoom = Controller.getCurrentController().getViewController().getZoom();
            iconR.setLocation((int) (iconR.x * zoom), iconR.y);
            iconR.setSize((int) (iconR.width * zoom), (int) (iconR.height * zoom));
            iconR.translate(bounds.x, bounds.y);
            if (iconR.contains(p)) {
              UpdateMonitoringFolderAction.updateNodesAgainstMonitoringDir(
                  getMonitorNodes(
                      Controller.getCurrentController().getViewController().getMap().getRootNode()),
                  false);
              return;
            }
          }
        }
      }
      //			StringBuilder sb = new StringBuilder();
      //			pdfHeaderExtraction(e, sb);
    }
    boolean openOnPage =
        ResourceController.getResourceController()
            .getBooleanProperty(PdfUtilitiesController.OPEN_PDF_VIEWER_ON_PAGE_KEY);

    if (!openOnPage) {
      this.mouseListener.mouseClicked(e);
      return;
    }

    if (
    /*wasFocused() && */ (e.getModifiers() & ~(InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK))
        == InputEvent.BUTTON1_MASK) {
      final MainView component = (MainView) e.getComponent();
      final ModeController modeController = Controller.getCurrentModeController();
      NodeModel node = null;
      try {
        node = ((MainView) e.getSource()).getNodeView().getModel();
      } catch (Exception ex) {
      }

      if (node == null) {
        node = modeController.getMapController().getSelectedNode();
      }

      if (component.isInFollowLinkRegion(e.getX())) {
        writeToLog(node);
      }
      if (!component.isInFollowLinkRegion(e.getX()) || !MonitoringUtils.isPdfLinkedNode(node)) {
        this.mouseListener.mouseClicked(e);
        return;
      }

      URI uri = Tools.getAbsoluteUri(node);
      if (uri == null) {
        this.mouseListener.mouseClicked(e);
        return;
      }

      IAnnotation annotation = null;
      try {
        annotation = node.getExtension(AnnotationModel.class);
      } catch (Exception ex) {
      }

      LinkController.getController().onDeselect(node);
      if (!PdfUtilitiesController.getController().openPdfOnPage(uri, annotation)) {
        this.mouseListener.mouseClicked(e);
        return;
      }
      LinkController.getController().onSelect(node);

    } else {
      this.mouseListener.mouseClicked(e);
    }
  }
 /** opens a {@link URI} */
 public void loadUri(final URI uri) {
   LinkController.getController().loadURI(uri);
 }