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>getToolTipText</code>
  *
  * @return - <code>String</code> -
  */
 public String getToolTipText() {
   if (slot.getTokenList().size() > 0) {
     return ((PwToken) slot.getTokenList().get(0)).toString();
   } else {
     return "";
   }
 } // end getToolTipText
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>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 #5
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