Пример #1
0
 /**
  * Returns a figure corresponding to this image
  *
  * @param image a image
  * @return a figure corresponding to this image
  */
 public IFigure getFigure(Image image) {
   IMapMode mm =
       MapModeUtil.getMapMode(
           ((IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class))
               .getFigure());
   ImageFigure fig = new ImageFigure();
   fig.setImage(image);
   fig.setSize(mm.DPtoLP(image.getBounds().width), mm.DPtoLP(image.getBounds().height));
   return fig;
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.draw2d.Figure#setBounds(org.eclipse.draw2d.geometry.Rectangle)
   */
  public void setBounds(Rectangle rect) {
    Dimension devDim = new Dimension(rect.getSize());
    MapModeUtil.getMapMode(this).LPtoDP(devDim);
    setRenderedImage(getRenderedImage(devDim));

    super.setBounds(rect);
  }
Пример #3
0
  private static void setBrightness() {
    if (image.isDisposed()) {
      return;
    }

    ImageData imageData = image.getImageData();

    for (int x = 0; x < imageData.width; x++) {
      for (int y = 0; y < imageData.height; y++) {
        RGB rgb = imageData.palette.getRGB(imageData.getPixel(x, y));
        float[] hsb = rgb.getHSB();

        hsb[2] = hsb[2] + 0.1f;
        if (hsb[2] > 1.0f) {
          hsb[2] = 1.0f;
        }

        //				hsb[1] = hsb[1] - 0.1f;
        //				if (hsb[1] < 0.0f) {
        //					hsb[1] = 0.0f;
        //				}
        RGB newRGB = new RGB(hsb[0], hsb[1], hsb[2]);

        int pixel = imageData.palette.getPixel(newRGB);
        imageData.setPixel(x, y, pixel);
      }
    }

    image.dispose();
    image = new Image(Display.getDefault(), imageData);

    imageFigure.setImage(image);
  }
Пример #4
0
 protected void paintFigure(Graphics graphics) {
   graphics.setAntialias(SWT.ON);
   if (control != null && !control.isDisposed() && control.isEnabled()) {
     graphics.setAlpha(0xff);
   } else {
     graphics.setAlpha(0x80);
   }
   super.paintFigure(graphics);
 }
Пример #5
0
  public int setVerticalLocation(Point parentTopCenter, int currentHeight) {
    Dimension topSize = fTopChannel.getSize();
    Dimension pipelineSize = getSize();
    Dimension headerSize = fHeader.getSize();
    Dimension arrowSize = fArrow.getSize();
    Dimension bottomSize = fBottomChannel.getSize();

    if (fTopChannel.setSelf(parentTopCenter.getTranslated(-topSize.width / 2, currentHeight), true))
      currentHeight += topSize.height;

    setLocation(parentTopCenter.getTranslated(-pipelineSize.width / 2, currentHeight));
    fHeader.setLocation(
        parentTopCenter.getTranslated(
            -pipelineSize.width / 2 + IStreamItGraphConstants.MARGIN / 2,
            IStreamItGraphConstants.MARGIN / 2 + currentHeight));

    if (!isExpanded()) {
      // collapsed location
      fArrow.setLocation(
          parentTopCenter.getTranslated(
              -arrowSize.width / 2,
              IStreamItGraphConstants.MARGIN / 2 + headerSize.height + currentHeight));
      currentHeight += pipelineSize.height;

    } else {
      // expanded location
      fArrow.setLocation(
          parentTopCenter.getTranslated(
              -pipelineSize.width / 2 + IStreamItGraphConstants.MARGIN / 2,
              IStreamItGraphConstants.MARGIN / 2 + headerSize.height + currentHeight));

      int last = fChildren.size() - 1;
      for (int i = 0; i < last + 1; i++)
        currentHeight =
            ((IStreamStructureWidget) fChildren.get(i))
                .setVerticalLocation(parentTopCenter, currentHeight);
    }

    if (fBottomChannel.setSelf(
        parentTopCenter.getTranslated(-bottomSize.width / 2, currentHeight), false))
      currentHeight += bottomSize.height;

    return currentHeight;
  }
Пример #6
0
 /** @see org.eclipse.draw2d.Figure#paint(org.eclipse.draw2d.Graphics) */
 public void paint(Graphics graphics) {
   super.paint(graphics);
   computeHandlerIconPositions(ModelHelper.isHorizontalLayout(getModel()));
   if (hasFH) {
     graphics.pushState();
     graphics.setClip(faultImageFigure.getBounds().getCopy());
     faultImageFigure.paint(graphics);
     graphics.popState();
   }
   if (hasEH) {
     graphics.pushState();
     graphics.setClip(eventImageFigure.getBounds().getCopy());
     eventImageFigure.paint(graphics);
     graphics.popState();
   }
 }
  public DashboardFigure() {
    imgReg = Activator.getDefault().getImageRegistry();
    add(
        logoFigure =
            new ImageFigure() {

              @Override
              protected void paintFigure(Graphics graphics) {
                if (getImage() != null) {
                  graphics.drawImage(
                      getImage(), new Rectangle(getImage().getBounds()), getBounds());
                }
              }
            });
    Image logoImage = imgReg.get(Activator.IMG_MDA_ID);
    if (logoImage != null) {
      logoFigure.setImage(logoImage);
    }
    initFigure.setSize(20, 20);
    initFigure.setBackgroundColor(DASHBOARD_FG);
    add(initFigure);
    add(methodoFigure = createMethodologyFigure("Methodology"));
    add(processFigure = createProcessFigure("Process"));
    endFigure.setSize(20, 20);
    endFigure.setBackgroundColor(DASHBOARD_FG);
    add(endFigure);
    add(init2methoFlow = createFlowFigure(true));
    add(metho2processFlow = createFlowFigure(true));
    add(process2endFlow = createFlowFigure(true));
    add(statusFigure = new Figure());
    statusFigure.setFont(JFaceResources.getBannerFont());
    ToolbarLayout statusLayout = new ToolbarLayout();
    statusLayout.setStretchMinorAxis(false);
    statusFigure.setLayoutManager(statusLayout);
    statusFigure.add(new Label());
    statusFigure.add(new Label());
    setLayoutManager(new DashboardLayout());
    setBorder(new MarginBorder(10));
    setBackgroundColor(DASHBOARD_BG);
    setForegroundColor(DASHBOARD_FG);
  }
Пример #8
0
 public void setImage(Image img) {
   radioBt.setImage(img);
 }
Пример #9
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);
    }
  }
 @Override
 public void paint(Graphics graphics) {
   // TODO Auto-generated method stub
   super.paint(graphics);
 }
 @Override
 protected void paintClientArea(Graphics graphics) {
   // TODO Auto-generated method stub
   super.paintClientArea(graphics);
 }