public AbstractLabeledFigure(Figure shape, Color borderColor, Color fillColor) {
    this.defaultBorderColor = borderColor;
    this.defaultFillColor = fillColor;

    setCornerDimensions(new Dimension(12, 12));

    setFill(false);
    setBorder(new MarginBorder(1));

    label = createLabel();
    label.setBorder(new MarginBorder(1, 6, 1, 6));
    label.setForegroundColor(ColorConstants.black);
    label.setOpaque(true);
    this.shape = shape;

    setLayoutManager(createFigureLayout());
    doAddShape(shape);
    doAddLabel(label);

    setBorderColor(null);
    setFillColor(null);

    setMinimumSize(new Dimension(50, -1));
    setMaximumSize(new Dimension(300, 100));
  }
  protected IFigure createBaseFigure() {
    Image image = null;
    byte[] icon = null;

    ComponentInterface ci =
        ((WorkflowNode) getModel())
            .getComponentDescription()
            .getComponentInstallation()
            .getComponentRevision()
            .getComponentInterface();

    if (ci.getSize() == ComponentSize.SMALL) {
      icon = ((WorkflowNode) getModel()).getComponentDescription().getIcon24();
    } else {
      icon = ((WorkflowNode) getModel()).getComponentDescription().getIcon32();
    }
    if (icon != null) {
      try {
        image = new Image(Display.getCurrent(), new ByteArrayInputStream(icon));
      } catch (SWTException e) {
        // The images of integrated tools may be broken, so the default will be used.
        LogFactory.getLog(getClass()).info("Could not load tool icon, loading default. ", e);
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_32);
      }
    } else if (ci.getIdentifier().startsWith(ComponentUtils.MISSING_COMPONENT_PREFIX)) {
      if (ci.getSize() == ComponentSize.SMALL) {
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_24_GREY);
      } else {
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_32_GREY);
      }
    } else {
      if (ci.getSize() == ComponentSize.SMALL) {
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_24);
      } else {
        image = ImageManager.getInstance().getSharedImage(StandardImages.RCE_LOGO_32);
      }
    }
    Color color = getColor(ci);

    if (ci.getSize() == ComponentSize.SMALL) {
      IconLabel iconLabel = new IconLabel(image, ci);
      iconLabel.setOpaque(true);
      iconLabel.setBorder(null);
      iconLabel.setBackgroundColor(color);
      return iconLabel;
    } else {
      final String labelText = ((WorkflowNode) getModel()).getName();
      final Label label = new Label(labelText, image);
      label.setTextPlacement(PositionConstants.SOUTH);
      label.setBorder(new LineBorder());
      label.setOpaque(true);
      label.setBackgroundColor(color);
      return label;
    }
  }
 /** @generated */
 protected IFigure createSelectionFeedbackFigure() {
   if (getHostFigure() instanceof Label) {
     Label feedbackFigure = new Label();
     feedbackFigure.setOpaque(true);
     feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected);
     feedbackFigure.setForegroundColor(ColorConstants.menuForegroundSelected);
     return feedbackFigure;
   } else {
     RectangleFigure feedbackFigure = new RectangleFigure();
     feedbackFigure.setFill(false);
     return feedbackFigure;
   }
 }
    public InterceptorsFigure() {
      ToolbarLayout layout = new ToolbarLayout();
      setLayoutManager(layout);
      setBorder(new LineBorder(ColorConstants.black, 1));

      /* Header Label */
      Label constantLabel = new Label("Interceptors");
      constantLabel.setLabelAlignment(PositionConstants.LEFT);
      constantLabel.setIcon(
          S2EditorUI.getImageDescriptor("icons/arraypartition_obj.gif").createImage());
      constantLabel.setBackgroundColor(new Color(null, 0xb7, 0xe4, 0xa8));
      constantLabel.setOpaque(true);
      constantLabel.setForegroundColor(ColorConstants.titleForeground);
      constantLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
      add(constantLabel);

      bodyFigure = new BodyFigure();
      add(bodyFigure);
    }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.gef.editparts.AbstractConnectionEditPart#createFigure()
   */
  @Override
  protected IFigure createFigure() {
    PolylineConnection connection = new PolylineConnection();
    PolygonDecoration decoration = new PolygonDecoration();

    decoration.setTemplate(PolygonDecoration.TRIANGLE_TIP);

    connection.setTargetDecoration(decoration);
    connection.setLineWidth(2);

    if (getCastedModel().isAlternate()) {
      ConditionalElement prevous = (ConditionalElement) getCastedModel().getPrevous();
      Label conditionLbl = new Label("[" + prevous.getAlternativeLabel() + "]");

      conditionLbl.setOpaque(true);
      connection.add(conditionLbl, new MidpointLocator(connection, 0));
    }

    return connection;
  }
  /**
   * @param contents IFigure
   * @param name String
   * @param route DotRoute
   * @return PolylineConnection
   */
  private PolylineConnection addConnectionFromRoute(
      final IFigure contents, final String name, final DotRoute route) {
    final float[] coords = new float[6];
    final ArrayList<AbsoluteBendpoint> bends = new ArrayList<AbsoluteBendpoint>();
    boolean isFirstPoint = true;
    final Point min = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
    final Point max = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE);

    for (final PathIterator ite =
            new FlatteningPathIterator(
                route.getPath().getPathIterator(new AffineTransform()), PATH_ITERATOR_FLATNESS);
        !ite.isDone();
        ite.next()) {
      final int segType = ite.currentSegment(coords);

      switch (segType) {
        case PathIterator.SEG_MOVETO:
          if (isFirstPoint) {
            addBendPoint(coords, bends, min, max);
          } else {
            LOG.error("Got SEG_MOVETO after first point");
          }
          break;

        case PathIterator.SEG_LINETO:
          addBendPoint(coords, bends, min, max);
          break;

        default:
          LOG.error("Unexpected segment type " + segType);
          break;
      }

      isFirstPoint = false;
    }

    final Rectangle bounds = new Rectangle(min, max);
    final PolylineConnection conn = new PolylineConnection();

    final Point sourcePoint = bends.remove(0);
    final Point targetPoint;
    if (route.getEndPt() != null) {
      targetPoint = new PrecisionPoint(route.getEndPt().getX(), route.getEndPt().getY());
    } else {
      targetPoint = bends.remove(bends.size() - 1);
    }
    conn.setSourceAnchor(new XYRelativeAnchor(conn, sourcePoint));
    conn.setTargetAnchor(new XYRelativeAnchor(conn, targetPoint));

    if (bends.isEmpty()) {
      conn.setConnectionRouter(null);
    } else {
      conn.setConnectionRouter(new BendpointConnectionRouter());
      conn.setRoutingConstraint(bends);
    }

    if (name != null) {
      final Label label = new Label(name);
      label.setOpaque(true);
      label.setBackgroundColor(ColorConstants.buttonLightest);
      label.setBorder(new LineBorder());
      label.setFont(Application.getInstance().getFont(Application.LINK_FONT));
      final ConnectionLocator locator = new MidpointLocator(conn, bends.size() / 2);
      locator.setRelativePosition(PositionConstants.CENTER);
      // Includes the label in the connection bounds.
      // Worst case scenario, the label is on the connection edge.
      final Dimension labelSize = label.getPreferredSize();
      bounds.expand(labelSize.width, labelSize.height);
      conn.add(label, locator);
    }

    contents.add(conn, bounds);

    return conn;
  }
 public void setConnName(String newName) {
   lblCnnName.setText(modifyString(newName));
   if (newName == null || newName.trim().length() == 0) lblCnnName.setOpaque(false);
   else lblCnnName.setOpaque(true);
 }