Ejemplo n.º 1
0
 /* (non-Javadoc)
  * @see streamit.eclipse.debugger.graph.IStreamStructureWidget#getStaticId()
  */
 public String getStaticId() {
   return fModel.getStaticId();
 }
Ejemplo n.º 2
0
 /* (non-Javadoc)
  * @see streamit.eclipse.debugger.graph.IStream#getId()
  */
 public String getRuntimeId() {
   return fModel.getRuntimeId();
 }
Ejemplo n.º 3
0
 /* (non-Javadoc)
  * @see streamit.eclipse.debugger.graph.Stream#getNameWithId()
  */
 public String getNameWithRuntimeId() {
   return fModel.getNameWithRuntimeId();
 }
Ejemplo n.º 4
0
 /* (non-Javadoc)
  * @see streamit.eclipse.debugger.graph.Stream#getNameWithoutId()
  */
 public String getNameWithoutId() {
   return fModel.getNameWithoutId();
 }
Ejemplo n.º 5
0
  public PipelineWidget(
      StreamStructure model,
      String streamNameWithId,
      OptionData optionData,
      Figure parent,
      boolean forward,
      boolean verticalLayout,
      boolean lastChild,
      Dimension parentSize,
      StreamItViewFactory factoryInst)
      throws DebugException {
    super();
    fModel = (Pipeline) model;

    // create pipeline
    new StreamStructureSelector(this);
    String pipelineName = getNameWithRuntimeId();
    fExpanded = optionData.containsStream(pipelineName, false);
    Dimension pipelineSize = FigureUtilities.getTextExtents(pipelineName, factoryInst.getFont());

    // pipeline style
    if (optionData.isHideLines() && fExpanded) setOutline(false);
    else setBorder(new LineBorder());
    setOpaque(true);
    setForegroundColor(ColorConstants.menuForeground);
    setBackgroundColor(ColorConstants.white);

    // possible highlight
    if (streamNameWithId.equals(pipelineName)) StreamStructureSelector.setSelection(this);

    if (!fExpanded) {

      // collapsed content
      fHeader = new Label(pipelineName, factoryInst.getPlus());
      pipelineSize.expand(fHeader.getIconTextGap() + factoryInst.getImageWidth(), 0);
      factoryInst.roundUpEven(pipelineSize);
      fHeader.setSize(pipelineSize);
      add(fHeader);

      pipelineSize.expand(
          IStreamItGraphConstants.MARGIN,
          factoryInst.getArrowHeight() + IStreamItGraphConstants.MARGIN);
    } else {

      // expanded content
      fHeader = new Label(pipelineName, factoryInst.getMinus());
      pipelineSize.expand(fHeader.getIconTextGap() + factoryInst.getImageWidth(), 0);
      factoryInst.roundUpEven(pipelineSize);
      fHeader.setSize(pipelineSize);
      add(fHeader);

      // expanded children
      Vector children = fModel.getChildStreams();
      int last;
      if (forward) {
        last = children.size() - 1;
      } else {
        last = 0;
        Collections.reverse(children);
      }
      Dimension childrenSize =
          new Dimension(0, 0); // (width of widest child, total height of children)
      fChildren = new Vector();
      Object child;
      for (int i = 0; i < children.size(); i++) {
        child = children.get(i);
        if (child instanceof Filter) {
          fChildren.add(
              new FilterWidget(
                  (Filter) child,
                  streamNameWithId,
                  optionData,
                  this,
                  forward,
                  true,
                  i == last,
                  childrenSize,
                  factoryInst));
        } else if (child instanceof Pipeline) {
          fChildren.add(
              new PipelineWidget(
                  (Pipeline) child,
                  streamNameWithId,
                  optionData,
                  this,
                  forward,
                  true,
                  i == last,
                  childrenSize,
                  factoryInst));
        } else if (child instanceof SplitJoin) {
          fChildren.add(
              new SplitJoinWidget(
                  (SplitJoin) child,
                  streamNameWithId,
                  optionData,
                  this,
                  forward,
                  true,
                  i == last,
                  childrenSize,
                  factoryInst));
        } else if (child instanceof FeedbackLoop) {
          fChildren.add(
              new FeedbackLoopWidget(
                  (FeedbackLoop) child,
                  streamNameWithId,
                  optionData,
                  this,
                  forward,
                  true,
                  i == last,
                  childrenSize,
                  factoryInst));
        }
      }

      // expanded size
      if (fChildren.size() == 0) {
        pipelineSize.width =
            IStreamItGraphConstants.MARGIN * 2
                + Math.max(
                    childrenSize.width,
                    pipelineSize.width * 2 + IStreamItGraphConstants.MARGIN * 3);
        setOutline(true);
        setBorder(new LineBorder());
      } else {
        pipelineSize.width =
            IStreamItGraphConstants.MARGIN * 2
                + Math.max(
                    childrenSize.width,
                    pipelineSize.width * 2
                        + IStreamItGraphConstants.MARGIN * 3
                        + ((IStreamStructureWidget) fChildren.get(0)).getTopChannelToggleWidth()
                            * 2);
      }
      pipelineSize.height =
          Math.max(childrenSize.height, pipelineSize.height + factoryInst.getArrowHeight());
    }
    setSize(pipelineSize);

    // content arrow
    fArrow = new ImageFigure(factoryInst.getArrow(forward));
    fArrow.setSize(factoryInst.getArrowWidth(), factoryInst.getArrowHeight());
    add(fArrow);

    // create channels
    if (forward) {
      fTopChannel =
          new ChannelWidget(
              fModel.getInputChannel(),
              pipelineName + IStreamItGraphConstants.ONE_CHAR,
              parent,
              forward,
              lastChild,
              optionData,
              factoryInst);
      fBottomChannel =
          new ChannelWidget(
              fModel.getOutputChannel(),
              pipelineName + IStreamItGraphConstants.ZERO_CHAR,
              parent,
              forward,
              lastChild,
              optionData,
              factoryInst);

      fTopChannel.grayData(
          Integer.parseInt(fModel.getMaxPeeked()) - Integer.parseInt(fModel.getPopped()));
    } else {
      fBottomChannel =
          new ChannelWidget(
              fModel.getInputChannel(),
              pipelineName + IStreamItGraphConstants.ONE_CHAR,
              parent,
              forward,
              lastChild,
              optionData,
              factoryInst);
      fTopChannel =
          new ChannelWidget(
              fModel.getOutputChannel(),
              pipelineName + IStreamItGraphConstants.ZERO_CHAR,
              parent,
              forward,
              lastChild,
              optionData,
              factoryInst);

      fBottomChannel.grayData(
          Integer.parseInt(fModel.getMaxPeeked()) - Integer.parseInt(fModel.getPopped()));
    }

    fTopChannel.turnOff(fExpanded);
    fBottomChannel.turnOff(fExpanded);
    ((IStreamStructureWidget) parent)
        .setChannelExpanded(fTopChannel.isExpanded(), fBottomChannel.isExpanded());

    // parent content
    parent.add(this);

    // parent size
    if (verticalLayout) {
      // (total height of children, width of widest child)
      parentSize.height = parentSize.height + fTopChannel.getSize().height + pipelineSize.height;
      if (lastChild) parentSize.height += fBottomChannel.getSize().height;
      parentSize.width = Math.max(parentSize.width, pipelineSize.width);
    } else {
      // (height of tallest child, total width of children)
      parentSize.height =
          Math.max(
              parentSize.height,
              fTopChannel.getSize().height + pipelineSize.height + fBottomChannel.getSize().height);
      parentSize.width =
          parentSize.width + Math.max(pipelineSize.width, fTopChannel.getSize().width);
    }
  }