public GaugeFigure() {
    super();
    transparent = true;
    scale.setScaleLineVisible(false);
    scale.setTickLabelSide(LabelSide.Secondary);
    ramp.setRampWidth(10);

    valueLabel = new Label();
    valueLabel.setFont(DEFAULT_LABEL_FONT);

    needle = new Needle();
    needle.setFill(true);
    needle.setOutline(false);

    needleCenter = new NeedleCenter();
    needleCenter.setOutline(false);

    setLayoutManager(new GaugeLayout());
    add(ramp, GaugeLayout.RAMP);
    add(scale, GaugeLayout.SCALE);
    add(valueLabel, GaugeLayout.VALUE_LABEL);
    add(needle, GaugeLayout.NEEDLE);
    add(needleCenter, GaugeLayout.NEEDLE_CENTER);
    addFigureListener(
        new FigureListener() {
          public void figureMoved(IFigure source) {
            ramp.setDirty(true);
            revalidate();
          }
        });
  }
Beispiel #2
0
  /**
   * Set the label that displays the text.
   *
   * @param textLabel the label to display the text, may be the same as the icon label or <code>null
   *     </code> to ignore the text
   * @see #setIconLabel(Label)
   */
  public void setTextLabel(Label textLabel) {
    this.textLabel = textLabel;

    textLabel.setFont(getFont());

    if (text != null) {
      textLabel.setText(text);
    }
  }
  /**
   * Instantiates a new node figure.
   *
   * @param name the name
   * @param width the weight
   */
  public SimpleNodeFigure(Node node, int width, MouseListener mouseListener) {
    super();

    this.node = node;

    LineBorder b = new LineBorder();
    b.setColor(NodeUtil.FG_COLOR);
    setBorder(b);

    textFigure = new RectangleFigure();
    text = new Label(getNodeName());
    text.setForegroundColor(NodeUtil.FG_COLOR_DARK);

    setSize(width, 10);

    textFigure.add(text);

    hideButton = new RectangleFigure();

    hideSymbol = new Label(getSymbol());
    hideSymbol.setSize(10, 10);
    hideSymbol.setTextAlignment(PositionConstants.CENTER);

    hideSymbol.setFont(hideButtonFont);
    hideSymbol.setForegroundColor(NodeUtil.FG_COLOR_DARK);
    hideButton.add(hideSymbol);
    hideButton.setBackgroundColor(exitClor);
    hideButton.addMouseListener(mouseListener);
    hideButton.addMouseMotionListener(
        new MouseMotionListener() {

          @Override
          public void mouseMoved(MouseEvent me) {}

          @Override
          public void mouseHover(MouseEvent me) {}

          @Override
          public void mouseExited(MouseEvent me) {
            hideButton.setBackgroundColor(exitClor);
          }

          @Override
          public void mouseEntered(MouseEvent me) {
            hideButton.setBackgroundColor(entredClor);
          }

          @Override
          public void mouseDragged(MouseEvent me) {}
        });
    hideButton.setSize(10, 10);

    setLayoutManager(new XYLayout());

    add(textFigure);
  }
Beispiel #4
0
 private String abbreviateLabel(Label label, String labelText, int currentLength) {
   label.setText(labelText);
   if (label.getFont() == null) {
     label.setFont(Display.getDefault().getSystemFont());
   }
   if (label.getTextBounds().width > MAX_LABEL_WIDTH) {
     String shorterLabelText = "";
     shorterLabelText =
         StringUtils.abbreviateMiddle(label.getText(), LABEL_TEXT_SEPARATOR, currentLength);
     currentLength--;
     label.setText(shorterLabelText);
     abbreviateLabel(label, shorterLabelText, currentLength);
   }
   return label.getText();
 }
 /**
  * @param contents Draw2dGraph
  * @param node IVertex
  * @param color Color
  * @param busLabel String
  * @param busId String String
  * @return PolylineConnection
  */
 private PolylineConnection createBusConnexion(
     final Draw2dGraph contents,
     final IVertex node,
     final Color color,
     final String busId,
     final String busLabel) {
   final PolylineConnection conn =
       addConnectionFromRoute(contents, null, (DotRoute) node.getAttr(busId));
   conn.setForegroundColor(color);
   contents.add(conn, conn.getBounds());
   final Label label =
       new Label(
           busLabel + " " + node.getName(),
           Application.getInstance().getImage(Application.LINK_ICON));
   label.setFont(Application.getInstance().getBoldFont(Application.TOOLTIP_FONT));
   conn.setToolTip(label);
   return conn;
 }
    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);
    }
Beispiel #7
0
  public MeterFigure() {
    super();
    // TODO, remove this if clip is supported by RAP
    if (SWT.getPlatform().startsWith("rap")) // $NON-NLS-1$
    ramp.setVisible(false);
    setTransparent(false);
    scale.setScaleLineVisible(false);

    ((RoundScale) scale).setStartAngle(180 - SPACE_ANGLE);
    ((RoundScale) scale).setEndAngle(SPACE_ANGLE);
    ramp.setRampWidth(12);
    setLoColor(XYGraphMediaFactory.getInstance().getColor(XYGraphMediaFactory.COLOR_YELLOW));
    setHiColor(XYGraphMediaFactory.getInstance().getColor(XYGraphMediaFactory.COLOR_YELLOW));

    valueLabel = new Label();
    valueLabel.setFont(DEFAULT_LABEL_FONT);
    needle = new Needle();
    needle.setFill(true);
    needle.setOutline(false);

    //	needleCenter = new Ellipse();
    //	needleCenter.setOutline(false);

    setLayoutManager(new XMeterLayout());
    add(ramp, XMeterLayout.RAMP);
    add(scale, XMeterLayout.SCALE);
    add(needle, XMeterLayout.NEEDLE);
    //	add(needleCenter, XMeterLayout.NEEDLE_CENTER);
    add(valueLabel, XMeterLayout.VALUE_LABEL);

    addFigureListener(
        new FigureListener() {
          public void figureMoved(IFigure source) {
            ramp.setDirty(true);
            revalidate();
          }
        });
  }
Beispiel #8
0
 private void setTabFigureProperty(int index, TabProperty tabProperty, final Object newValue) {
   Label label = getTabFigure().getTabLabel(index);
   switch (tabProperty) {
     case TITLE:
       label.setText((String) newValue);
       updateTabAreaSize();
       break;
     case FONT:
       label.setFont(((OPIFont) newValue).getSWTFont());
       updateTabAreaSize();
       break;
     case BACKCOLOR:
       getTabFigure().setTabColor(index, ((OPIColor) newValue).getSWTColor());
       break;
     case FORECOLOR:
       label.setForegroundColor(
           CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
       break;
     case ENABLED:
       getTabFigure().setTabEnabled(index, (Boolean) newValue);
       break;
     case ICON_PATH:
       getTabFigure()
           .setIconPath(
               index,
               getWidgetModel().toAbsolutePath((IPath) newValue),
               new IJobErrorHandler() {
                 public void handleError(Exception e) {
                   String message = "Failed to load image from " + newValue + "\n" + e;
                   Activator.getLogger().log(Level.WARNING, message, e);
                   ConsoleService.getInstance().writeError(message);
                 }
               });
       break;
     default:
       break;
   }
 }
 /** @generated */
 protected void updateLabel(Label target) {
   Label source = (Label) getHostFigure();
   target.setText(source.getText());
   target.setTextAlignment(source.getTextAlignment());
   target.setFont(source.getFont());
 }
  /**
   * @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;
  }