예제 #1
0
 private Rectangle getROIFromGeoBounds(PrecisionRectangle roiBounds) {
   PrecisionPoint lt =
       ((GraphArea) getParent()).getDataLocation(roiBounds.preciseX(), roiBounds.preciseY());
   PrecisionPoint rb =
       ((GraphArea) getParent())
           .getDataLocation(
               roiBounds.preciseX() + roiBounds.preciseWidth(),
               roiBounds.preciseY() + roiBounds.preciseHeight());
   return new Rectangle(
       (int) Math.round(lt.preciseX()) + intensityGraphFigure.getCropLeft(),
       (int) Math.round(lt.preciseY()) + intensityGraphFigure.getCropTop(),
       (int) Math.ceil(rb.preciseX() - lt.preciseX()),
       (int) Math.ceil(rb.preciseY() - lt.preciseY()));
 }
예제 #2
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();
          }
        });
  }
예제 #3
0
 private PrecisionRectangle getGeoBoundsFromROI(Rectangle roiDataBounds) {
   PrecisionPoint lt =
       ((GraphArea) getParent())
           .getGeoLocation(
               roiDataBounds.preciseX() - intensityGraphFigure.getCropLeft(),
               roiDataBounds.preciseY() - intensityGraphFigure.getCropTop());
   PrecisionPoint rb =
       ((GraphArea) getParent())
           .getGeoLocation(
               roiDataBounds.preciseX()
                   + roiDataBounds.preciseWidth()
                   - intensityGraphFigure.getCropLeft(),
               roiDataBounds.preciseY()
                   + roiDataBounds.preciseHeight()
                   - intensityGraphFigure.getCropTop());
   return new PrecisionRectangle(
       lt.preciseX() - getBounds().x,
       lt.preciseY() - getBounds().y,
       rb.preciseX() - lt.preciseX(),
       rb.preciseY() - lt.preciseY());
 }