Example #1
0
  /**
   * Constructor of ROI figure.
   *
   * @param name name of the ROI. It must be unique for this graph.
   * @param color color of the ROI.
   * @param roiListener listener on ROI updates. Can be null.
   * @param roiInfoProvider provides information for the ROI. Can be null.
   */
  public ROIFigure(
      IntensityGraphFigure intensityGraphFigure,
      String name,
      Color color,
      IROIListener roiListener,
      IROIInfoProvider roiInfoProvider) {
    this.intensityGraphFigure = intensityGraphFigure;
    this.name = name;
    this.roiListener = roiListener;
    this.roiInfoProvider = roiInfoProvider;
    setToolTip(new Label(name));
    setBackgroundColor(ColorConstants.white);
    setForegroundColor(ColorConstants.black);
    roiRectFigure =
        new RectangleFigure() {
          public boolean containsPoint(int x, int y) {
            if (!super.containsPoint(x, y)) return false;
            return !Rectangle.SINGLETON.setBounds(getBounds()).shrink(3, 3).contains(x, y);
          }
        };
    roiRectFigure.setCursor(Cursors.SIZEALL);
    roiRectFigure.setFill(false);
    roiRectFigure.setOutline(true);
    roiRectFigure.setForegroundColor(color);
    ROIRectDragger roiRectDragger = new ROIRectDragger();
    roiRectFigure.addMouseListener(roiRectDragger);
    roiRectFigure.addMouseMotionListener(roiRectDragger);
    setFocusTraversable(true);
    setRequestFocusEnabled(true);
    resizeHandlers = new ResizeHandler[HANDLERS_COUNT];
    add(roiRectFigure);
    for (int i = 0; i < HANDLERS_COUNT; i++) {
      resizeHandlers[i] = new ResizeHandler(i);
      add(resizeHandlers[i]);
    }

    addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent fe) {
            for (Figure handler : resizeHandlers) {
              handler.setVisible(true);
            }
          }

          public void focusLost(FocusEvent fe) {
            for (Figure handler : resizeHandlers) {
              handler.setVisible(false);
            }
          }
        });
    intensityGraphFigure.addCroppedDataSizeListener(
        new ICroppedDataSizeListener() {

          public void croppedDataSizeChanged(int croppedDataWidth, int croppedDataHeight) {
            updateROIGeoBounds();
            updateChildrenBounds();
          }
        });
  }
  /**
   * 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);
  }