Example #1
0
  /**
   * <code>addSlotNavNode</code>
   *
   * @param slot - <code>PwSlot</code> -
   * @return - <code>SlotNavNode</code> -
   */
  protected final SlotNavNode addSlotNavNode(final PwSlot slot) {
    boolean isDraggable = true;
    PwTimeline timeline = partialPlan.getTimeline(slot.getTimelineId());

    //     System.err.println( "addSlotNavNode id = " + slot.getId());
    //     System.err.println( "entityNavNodeMap ");
    //     List keyList = new ArrayList( entityNavNodeMap.keySet());
    //     Iterator keyItr = keyList.iterator();
    //     while (keyItr.hasNext()) {
    //       Integer key = (Integer) keyItr.next();
    //       System.err.println( "  key " + key + " " + entityNavNodeMap.get( key).getClass());
    //     }

    SlotNavNode slotNavNode = (SlotNavNode) entityNavNodeMap.get(slot.getId());
    if (slotNavNode == null) {
      slotNavNode =
          new SlotNavNode(
              slot,
              new Point(
                  ViewConstants.TIMELINE_VIEW_X_INIT * 2, ViewConstants.TIMELINE_VIEW_Y_INIT * 2),
              getTimelineColor(timeline.getId()),
              isDraggable,
              this);
      entityNavNodeMap.put(slot.getId(), slotNavNode);
      jGoDocument.addObjectAtTail(slotNavNode);
    }
    return slotNavNode;
  } // end addSlotNavNode
Example #2
0
  /**
   * <code>init</code> - wait for instance to become displayable, determine appropriate font
   * metrics, and render the JGo navigator, and slot widgets
   *
   * <p>These functions are not done in the constructor to avoid: "Cannot measure text until a
   * JGoView exists and is part of a visible window". called by componentShown method on the JFrame
   * JGoView.setVisible( true) must be completed -- use SwingWorker in constructor
   */
  public final void init() {
    // wait for NavigatorView instance to become displayable
    if (!ViewGenerics.displayableWait(NavigatorView.this)) {
      closeView(this);
      return;
    }
    this.computeFontMetrics(this);

    jGoDocument = jGoView.getDocument();
    jGoDocument.addDocumentListener(createDocListener());
    renderInitialNode();

    NavigatorViewLayout layout = new NavigatorViewLayout(jGoDocument, startTimeMSecs);
    layout.performLayout();

    MDIInternalFrame contentFilterFrame = viewSet.getContentSpecWindow();
    int contentFilterMaxY =
        (int) (contentFilterFrame.getLocation().getY() + contentFilterFrame.getSize().getHeight());
    int delta =
        Math.min(
            ViewConstants.INTERNAL_FRAME_X_DELTA_DIV_4
                * ((PartialPlanViewSet) viewSet).getNavigatorFrameCnt(),
            (int)
                (PlanWorks.getPlanWorks().getSize().getHeight()
                    - contentFilterMaxY
                    - (ViewConstants.MDI_FRAME_DECORATION_HEIGHT * 2)));
    navigatorFrame.setLocation(
        (ViewConstants.INTERNAL_FRAME_X_DELTA / 2) + delta, contentFilterMaxY + delta);

    //     Rectangle documentBounds = jGoView.getDocument().computeBounds();
    //     jGoView.getDocument().setDocumentSize( (int) documentBounds.getWidth() +
    //                                            (ViewConstants.TIMELINE_VIEW_X_INIT * 2),
    //                                            (int) documentBounds.getHeight() +
    //                                            (ViewConstants.TIMELINE_VIEW_Y_INIT * 2));
    int maxViewWidth = (int) jGoView.getDocumentSize().getWidth();
    int maxViewHeight = (int) jGoView.getDocumentSize().getHeight();

    //     navigatorFrame.setSize
    //       ( maxViewWidth + ViewConstants.MDI_FRAME_DECORATION_WIDTH,
    //         maxViewHeight + ViewConstants.MDI_FRAME_DECORATION_HEIGHT);

    expandViewFrame(navigatorFrame, maxViewWidth, maxViewHeight);

    long stopTimeMSecs = System.currentTimeMillis();
    System.err.println(
        "   ... "
            + ViewConstants.NAVIGATOR_VIEW
            + " elapsed time: "
            + (stopTimeMSecs - startTimeMSecs)
            + " msecs.");
    startTimeMSecs = 0L;
    isLayoutNeeded = false;
    focusNode = null;
    // print out info for created nodes
    // iterateOverJGoDocument(); // slower - many more nodes to go thru
    // iterateOverNodes();
  } // end init
Example #3
0
  /**
   * <code>addNavigatorLinkNew</code>
   *
   * @param fromNode - <code>ExtendedBasicNode</code> -
   * @param link - <code>BasicNodeLink</code> -
   * @param linkType - <code>String</code> -
   * @return - <code>boolean</code> -
   */
  protected final boolean addNavigatorLinkNew(
      final ExtendedBasicNode fromNode, final BasicNodeLink link, final String linkType) {
    boolean areLinksChanged = false;
    if (link != null) {
      // links are always behind any nodes
      // jGoDocument.addObjectAtHead( link);
      // jGoDocument.addObjectAtTail( link);
      jGoDocument.insertObjectBefore(jGoDocument.findObject(fromNode), link);

      link.setInLayout(true);
      link.incrLinkCount();
      if (isDebugPrint) {
        System.err.println(
            linkType + " incr link: " + link.toString() + " to " + link.getLinkCount());
      }
      areLinksChanged = true;
    }
    return areLinksChanged;
  } // end addNavigatorLinkNew
Example #4
0
 /**
  * <code>addResourceNavNode</code>
  *
  * @param resource - <code>PwResource</code> -
  * @return - <code>ResourceNavNode</code> -
  */
 protected final ResourceNavNode addResourceNavNode(final PwResource resource) {
   boolean isDraggable = true;
   ResourceNavNode resourceNavNode = (ResourceNavNode) entityNavNodeMap.get(resource.getId());
   if (resourceNavNode == null) {
     resourceNavNode =
         new ResourceNavNode(
             resource,
             new Point(
                 ViewConstants.TIMELINE_VIEW_X_INIT * 2, ViewConstants.TIMELINE_VIEW_Y_INIT * 2),
             getTimelineColor(resource.getId()),
             isDraggable,
             this);
     entityNavNodeMap.put(resource.getId(), resourceNavNode);
     jGoDocument.addObjectAtTail(resourceNavNode);
   }
   return resourceNavNode;
 } // end addResourceNavNode
Example #5
0
 /**
  * <code>addTimelineNavNode</code>
  *
  * @param timeline - <code>PwTimeline</code> -
  * @return - <code>TimelineNavNode</code> -
  */
 protected final TimelineNavNode addTimelineNavNode(final PwTimeline timeline) {
   boolean isDraggable = true;
   TimelineNavNode timelineNavNode = (TimelineNavNode) entityNavNodeMap.get(timeline.getId());
   if (timelineNavNode == null) {
     timelineNavNode =
         new TimelineNavNode(
             timeline,
             new Point(
                 ViewConstants.TIMELINE_VIEW_X_INIT * 2, ViewConstants.TIMELINE_VIEW_Y_INIT * 2),
             getTimelineColor(timeline.getId()),
             isDraggable,
             this);
     entityNavNodeMap.put(timeline.getId(), timelineNavNode);
     jGoDocument.addObjectAtTail(timelineNavNode);
   }
   return timelineNavNode;
 } // end addTimelineNavNode
Example #6
0
 /**
  * <code>addModelClassNavNode</code>
  *
  * @param object - <code>PwObject</code> -
  * @return - <code>ModelClassNavNode</code> -
  */
 protected final ModelClassNavNode addModelClassNavNode(final PwObject object) {
   boolean isDraggable = true;
   ModelClassNavNode objectNavNode = (ModelClassNavNode) entityNavNodeMap.get(object.getId());
   if (objectNavNode == null) {
     objectNavNode =
         new ModelClassNavNode(
             object,
             new Point(
                 ViewConstants.TIMELINE_VIEW_X_INIT * 2, ViewConstants.TIMELINE_VIEW_Y_INIT * 2),
             getTimelineColor(object.getId()),
             isDraggable,
             this);
     entityNavNodeMap.put(object.getId(), objectNavNode);
     jGoDocument.addObjectAtTail(objectNavNode);
   }
   return objectNavNode;
 } // end addModelClassNavNode
Example #7
0
 /**
  * <code>addVariableNavNode</code>
  *
  * @param variable - <code>PwVariable</code> -
  * @return - <code>VariableNavNode</code> -
  */
 protected final VariableNavNode addVariableNavNode(final PwVariable variable) {
   // ConstraintNetwork.VariableNode
   boolean isDraggable = true;
   VariableNavNode variableNavNode = (VariableNavNode) entityNavNodeMap.get(variable.getId());
   if (variableNavNode == null) {
     variableNavNode =
         new VariableNavNode(
             variable,
             new Point(
                 ViewConstants.TIMELINE_VIEW_X_INIT * 2, ViewConstants.TIMELINE_VIEW_Y_INIT * 2),
             NavNodeGenerics.getVariableColor(variable, this),
             isDraggable,
             this);
     entityNavNodeMap.put(variable.getId(), variableNavNode);
     jGoDocument.addObjectAtTail(variableNavNode);
   }
   return variableNavNode;
 } // end renderVariableNode
Example #8
0
 /**
  * <code>addRuleInstanceNavNode</code>
  *
  * @param ruleInstance - <code>PwRuleInstance</code> -
  * @return - <code>RuleInstanceNavNode</code> -
  */
 protected final RuleInstanceNavNode addRuleInstanceNavNode(final PwRuleInstance ruleInstance) {
   boolean isDraggable = true;
   RuleInstanceNavNode ruleInstanceNavNode =
       (RuleInstanceNavNode) entityNavNodeMap.get(ruleInstance.getId());
   if (ruleInstanceNavNode == null) {
     ruleInstanceNavNode =
         new RuleInstanceNavNode(
             ruleInstance,
             new Point(
                 ViewConstants.TIMELINE_VIEW_X_INIT * 2, ViewConstants.TIMELINE_VIEW_Y_INIT * 2),
             ViewConstants.RULE_INSTANCE_BG_COLOR,
             isDraggable,
             this);
     entityNavNodeMap.put(ruleInstance.getId(), ruleInstanceNavNode);
     jGoDocument.addObjectAtTail(ruleInstanceNavNode);
   }
   return ruleInstanceNavNode;
 } // end addRuleInstanceNavNode
Example #9
0
 /**
  * <code>addTokenNavNode</code>
  *
  * @param token - <code>PwToken</code> -
  * @return - <code>TokenNavNode</code> -
  */
 protected final TokenNavNode addTokenNavNode(final PwToken token) {
   // TokenNetwork.TokenNode  TemporalExtent.TemporalNode
   // System.err.println( "addTokenNavNode id " + token.getId() + " " + token.getClass());
   boolean isDraggable = true;
   TokenNavNode tokenNavNode = (TokenNavNode) entityNavNodeMap.get(token.getId());
   if (tokenNavNode == null) {
     tokenNavNode =
         new TokenNavNode(
             token,
             new Point(
                 ViewConstants.TIMELINE_VIEW_X_INIT * 2, ViewConstants.TIMELINE_VIEW_Y_INIT * 2),
             NavNodeGenerics.getTokenColor(token, this),
             isDraggable,
             this);
     entityNavNodeMap.put(token.getId(), tokenNavNode);
     jGoDocument.addObjectAtTail(tokenNavNode);
   }
   return tokenNavNode;
 } // end addTokenNavNode
Example #10
0
 /**
  * <code>addConstraintNavNode</code>
  *
  * @param constraint - <code>PwConstraint</code> -
  * @return - <code>ConstraintNavNode</code> -
  */
 protected final ConstraintNavNode addConstraintNavNode(final PwConstraint constraint) {
   // ConstraintNetwork.ConstraintNode
   boolean isDraggable = true;
   PwVariable variable = (PwVariable) constraint.getVariablesList().get(0);
   ConstraintNavNode constraintNavNode =
       (ConstraintNavNode) entityNavNodeMap.get(constraint.getId());
   if (constraintNavNode == null) {
     constraintNavNode =
         new ConstraintNavNode(
             constraint,
             new Point(
                 ViewConstants.TIMELINE_VIEW_X_INIT * 2, ViewConstants.TIMELINE_VIEW_Y_INIT * 2),
             NavNodeGenerics.getVariableColor(variable, this),
             isDraggable,
             this);
     entityNavNodeMap.put(constraint.getId(), constraintNavNode);
     jGoDocument.addObjectAtTail(constraintNavNode);
   }
   return constraintNavNode;
 } // end renderConstraintNode
Example #11
0
  private void renderStepContent(String query) {
    getDocument().deleteContents();
    Color bgColor = ViewConstants.VIEW_BACKGROUND_COLOR;
    int x = 0, y = 5;
    Iterator transItr = transactionList.iterator();
    int i = 1;
    // System.err.println( "renderStepContent: transactionList " + transactionList);
    while (transItr.hasNext()) {
      x = 0;
      PwTransaction transaction = (PwTransaction) transItr.next();
      StepField stepNumField =
          new StepField(
              transaction.getStepNumber().toString(),
              new Point(x, y),
              JGoText.ALIGN_RIGHT,
              bgColor,
              viewableObject,
              vizView);
      jGoDocument.addObjectAtTail(stepNumField);
      stepNumField.setSize(
          (int) headerJGoView.getStepNumNode().getSize().getWidth(),
          (int) stepNumField.getSize().getHeight());
      x += headerJGoView.getStepNumNode().getSize().getWidth();

      keyField =
          new StepField(
              transaction.getId().toString(),
              new Point(x, y),
              JGoText.ALIGN_CENTER,
              bgColor,
              viewableObject);
      jGoDocument.addObjectAtTail(keyField);
      keyField.setSize(
          (int) headerJGoView.getKeyNode().getSize().getWidth(),
          (int) keyField.getSize().getHeight());
      x += headerJGoView.getKeyNode().getSize().getWidth();

      StepField typeField =
          new StepField(
              transaction.getType(),
              new Point(x, y),
              JGoText.ALIGN_CENTER,
              bgColor,
              viewableObject);
      jGoDocument.addObjectAtTail(typeField);
      typeField.setSize(
          (int) headerJGoView.getTypeNode().getSize().getWidth(),
          (int) typeField.getSize().getHeight());
      x += headerJGoView.getTypeNode().getSize().getWidth();

      if ((query.indexOf(" With ") >= 0) || ((query.indexOf(" With ") == -1) && key.equals(""))) {
        StepField objectKeyField =
            new StepField(
                transaction.getObjectId().toString(),
                new Point(x, y),
                JGoText.ALIGN_CENTER,
                bgColor,
                viewableObject);
        jGoDocument.addObjectAtTail(objectKeyField);
        objectKeyField.setSize(
            (int) headerJGoView.getObjectKeyNode().getSize().getWidth(),
            (int) objectKeyField.getSize().getHeight());
        x += headerJGoView.getObjectKeyNode().getSize().getWidth();
      }

      String objectName =
          NodeGenerics.trimName(
              transaction.getInfo()[0], headerJGoView.getObjectNameNode(), vizView);
      StepField objectNameField =
          new StepField(objectName, new Point(x, y), JGoText.ALIGN_CENTER, bgColor, viewableObject);
      jGoDocument.addObjectAtTail(objectNameField);
      objectNameField.setSize(
          (int) headerJGoView.getObjectNameNode().getSize().getWidth(),
          (int) objectNameField.getSize().getHeight());
      x += headerJGoView.getObjectNameNode().getSize().getWidth();

      String predicateName =
          NodeGenerics.trimName(
              transaction.getInfo()[1], headerJGoView.getPredicateNode(), vizView);
      StepField predicateField =
          new StepField(
              predicateName, new Point(x, y), JGoText.ALIGN_CENTER, bgColor, viewableObject);
      jGoDocument.addObjectAtTail(predicateField);
      predicateField.setSize(
          (int) headerJGoView.getPredicateNode().getSize().getWidth(),
          (int) predicateField.getSize().getHeight());
      x += headerJGoView.getPredicateNode().getSize().getWidth();

      String parameterName =
          NodeGenerics.trimName(
              transaction.getInfo()[2], headerJGoView.getParameterNode(), vizView);
      StepField parameterField =
          new StepField(
              parameterName, new Point(x, y), JGoText.ALIGN_CENTER, bgColor, viewableObject);
      jGoDocument.addObjectAtTail(parameterField);
      parameterField.setSize(
          (int) headerJGoView.getParameterNode().getSize().getWidth(),
          (int) parameterField.getSize().getHeight());
      x += headerJGoView.getParameterNode().getSize().getWidth();

      y += stepNumField.getSize().getHeight();
      i++;
    }
  } // end renderSteps