Example #1
0
 /**
  * <code>getLongestDuration</code>
  *
  * @param slot - <code>PwSlot</code> -
  * @param startTimeIntervalDomain - <code>PwDomain</code> -
  * @param endTimeIntervalDomain - <code>PwDomain</code> -
  * @return - <code>String</code> -
  */
 public static String getLongestDuration(
     PwSlot slot, PwDomain startTimeIntervalDomain, PwDomain endTimeIntervalDomain) {
   PwVariable durationVariable = null;
   if ((slot == null)
       || // free token
       (slot.getBaseToken() == null)) { // empty slot
     String upperBound = endTimeIntervalDomain.getUpperBound();
     String lowerBound = startTimeIntervalDomain.getLowerBound();
     if (upperBound.equals(PwDomain.PLUS_INFINITY)) {
       return PwDomain.PLUS_INFINITY;
     } else if (lowerBound.equals(PwDomain.MINUS_INFINITY)) {
       return PwDomain.PLUS_INFINITY;
     } else {
       return String.valueOf(
           endTimeIntervalDomain.getUpperBoundInt() - startTimeIntervalDomain.getLowerBoundInt());
     }
   } else {
     durationVariable = slot.getBaseToken().getDurationVariable();
     if (durationVariable != null) {
       return durationVariable.getDomain().getUpperBound();
     } else {
       return "0";
     }
   }
 } // end getLatestDuration
Example #2
0
  /**
   * <code>VariableNode</code> - constructor
   *
   * @param variable - <code>PwVariable</code> -
   * @param tokenNode - <code>TokenNode</code> -
   * @param variableLocation - <code>Point</code> -
   * @param backgroundColor - <code>Color</code> -
   * @param isFreeToken - <code>boolean</code> -
   * @param isDraggable - <code>boolean</code> -
   * @param partialPlanView - <code>PartialPlanView</code> -
   */
  public VariableNode(
      final PwVariable variable,
      final VariableContainerNode parentNode,
      final Point variableLocation,
      final Color backgroundColor,
      final boolean isDraggable,
      final PartialPlanView partialPlanView) {
    super(ViewConstants.PINCHED_RECTANGLE);
    this.variable = variable;
    this.partialPlanView = partialPlanView;
    containerNodeList = new ArrayList();
    containerNodeList.add(parentNode);
    constraintNodeList = new ArrayList();
    variableContainerLinkList = new ArrayList();
    this.backgroundColor = backgroundColor;

    inLayout = false;
    hasZeroConstraints = true;
    if (variable.getConstraintList().size() > 0) {
      hasZeroConstraints = false;
    }
    hasBeenVisited = false;

    isDebug = false;
    // isDebug = true;
    StringBuffer labelBuf = new StringBuffer(variable.getDomain().toString());
    labelBuf.append("\nkey=").append(variable.getId().toString());
    nodeLabel = labelBuf.toString();
    // System.err.println( "VariableNode: " + nodeLabel);

    configure(variableLocation, backgroundColor, isDraggable);
  } // end constructor
Example #3
0
 /**
  * <code>getShortestDuration</code>
  *
  * @param slot - <code>PwSlot</code> -
  * @param startTimeIntervalDomain - <code>PwDomain</code> -
  * @param endTimeIntervalDomain - <code>PwDomain</code> -
  * @return - <code>String</code> -
  */
 public static String getShortestDuration(
     PwSlot slot, PwDomain startTimeIntervalDomain, PwDomain endTimeIntervalDomain) {
   PwVariable durationVariable = null;
   if ((slot == null)
       || // free token
       (slot.getBaseToken() == null)) { // empty slot
     int startUpper = startTimeIntervalDomain.getUpperBoundInt();
     int endUpper = endTimeIntervalDomain.getUpperBoundInt();
     int startLower = startTimeIntervalDomain.getLowerBoundInt();
     int endLower = endTimeIntervalDomain.getLowerBoundInt();
     int valueStart = Math.max(startLower, startUpper);
     if (valueStart == PwDomain.PLUS_INFINITY_INT) {
       valueStart = Math.min(startLower, startUpper);
     }
     if (valueStart == PwDomain.MINUS_INFINITY_INT) {
       valueStart = 0;
     }
     int valueEnd = Math.min(endLower, endUpper);
     if (valueEnd == PwDomain.MINUS_INFINITY_INT) {
       valueEnd = Math.max(endLower, endUpper);
     }
     if (valueEnd == PwDomain.PLUS_INFINITY_INT) {
       valueEnd = valueStart;
     }
     return String.valueOf(Math.abs(valueEnd - valueStart));
   } else {
     durationVariable = slot.getBaseToken().getDurationVariable();
     if (durationVariable != null) {
       return durationVariable.getDomain().getLowerBound();
     } else {
       return "0";
     }
   }
 } // end getEarliestDuration
Example #4
0
  /**
   * <code>getStartEndIntervals</code> use startVariable for every token + the endVariable for the
   * last one if a slot is empty, and has no tokens, use the endVariable from the previous slot
   *
   * @param view - <code>VizView</code> -
   * @param slot - <code>PwSlot</code> -
   * @param previousToken - <code>PwToken</code> -
   * @param isLastSlot - <code>boolean</code> -
   * @return - <code>PwDomain[]</code> -
   */
  public static PwDomain[] getStartEndIntervals(
      VizView view,
      PwSlot slot,
      PwToken previousToken,
      boolean isLastSlot,
      boolean alwaysReturnEnd) {
    PwDomain[] intervalArray = new PwDomain[2];
    PwDomain startIntervalDomain = null;
    PwDomain endIntervalDomain = null;
    PwVariable intervalVariable = null, lastIntervalVariable = null;
    PwToken baseToken = slot.getBaseToken();
    PwDomain intervalDomain = null, lastIntervalDomain = null;
    if (baseToken == null) { // empty slot
      if ((previousToken == null)
          || // first slot
          (isLastSlot == true)) { // last slot
        intervalArray[0] = null;
        intervalArray[1] = null;
        return intervalArray;
      } else {
        // empty slot between filled slots
        intervalVariable = previousToken.getEndVariable();
      }
    } else if (isLastSlot || alwaysReturnEnd) {
      intervalVariable = baseToken.getStartVariable();
      lastIntervalVariable = baseToken.getEndVariable();
    } else {
      intervalVariable = baseToken.getStartVariable();
    }

    if (intervalVariable == null) {
      startIntervalDomain = intervalDomain;
    } else {
      startIntervalDomain = intervalVariable.getDomain();
    }
    // System.err.println( "startIntervalDomain " + startIntervalDomain.toString());

    if ((lastIntervalVariable != null) || (lastIntervalDomain != null)) {
      if (lastIntervalVariable == null) {
        endIntervalDomain = lastIntervalDomain;
      } else {
        endIntervalDomain = lastIntervalVariable.getDomain();
      }
      // System.err.println( "endIntervalDomain " + endIntervalDomain.toString());
    }
    if (alwaysReturnEnd && (endIntervalDomain == null)) {
      endIntervalDomain = startIntervalDomain;
    }
    intervalArray[0] = startIntervalDomain;
    intervalArray[1] = endIntervalDomain;
    return intervalArray;
  } // end getStartEndIntervals
Example #5
0
 /**
  * <code>getToolTipText</code>
  *
  * @return - <code>String</code> -
  */
 public String getToolTipText() {
   if (variable == null) {
     return null;
   }
   String operation = null;
   if (areNeighborsShown()) {
     operation = "close";
   } else {
     operation = "open";
   }
   StringBuffer tip = new StringBuffer("<html> ");
   boolean isVariableWithConstraints =
       (!hasZeroConstraints) && (partialPlanView instanceof ConstraintNetworkView);
   NodeGenerics.getVariableNodeToolTipText(variable, partialPlanView, tip);
   if (isDebug) {
     tip.append(" linkCnt ").append(String.valueOf(constraintLinkCount));
   }
   if (partialPlanView.getZoomFactor() > 1) {
     tip.append("<br>key=");
     tip.append(variable.getId().toString());
   }
   if (isVariableWithConstraints) {
     tip.append("<br> Mouse-L: ").append(operation);
   }
   return tip.append("</html>").toString();
 } // end getToolTipText
Example #6
0
 /**
  * <code>getToolTipText</code> - when over 1/8 scale overview variable node implements
  * OverviewToolTip
  *
  * @param isOverview - <code>boolean</code> -
  * @return - <code>String</code> -
  */
 public String getToolTipText(boolean isOverview) {
   StringBuffer tip = new StringBuffer("<html> ");
   NodeGenerics.getVariableNodeToolTipText(variable, partialPlanView, tip);
   tip.append("<br>key=");
   tip.append(variable.getId().toString());
   tip.append("</html>");
   return tip.toString();
 } // end getToolTipText
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>resetNode</code> - when closed by token close traversal
  *
  * @param isDebug - <code>boolean</code> -
  */
 public void resetNode(boolean isDebug) {
   setAreNeighborsShown(false);
   if (isDebug && (constraintLinkCount != 0)) {
     System.err.println(
         "reset variable node: "
             + variable.getId()
             + "; constraintLinkCount != 0: "
             + constraintLinkCount);
   }
   constraintLinkCount = 0;
   if (isDebug && (containerLinkCount != 0)) {
     System.err.println(
         "reset variable node: "
             + variable.getId()
             + "; containerLinkCount != 0: "
             + containerLinkCount);
   }
   containerLinkCount = 0;
 } // end resetNode
Example #9
0
 public boolean equals(VariableNode v) {
   return variable.getId().equals(v.getVariable().getId());
 }
Example #10
0
 /**
  * <code>toString</code>
  *
  * @return - <code>String</code> -
  */
 public String toString() {
   return variable.getId().toString();
 }