Esempio n. 1
0
 private void performAction(
     @NotNull MouseEvent e,
     @NotNull PairFunction<Integer, Point, GraphAction> actionConstructor) {
   int row = PositionUtil.getRowIndex(e.getPoint());
   if (row > getRowCount() - 1) {
     return;
   }
   Point point = calcPoint4Graph(e.getPoint());
   GraphFacade graphFacade = myDataPack.getGraphFacade();
   GraphAnswer answer = graphFacade.performAction(actionConstructor.fun(row, point));
   myUI.handleAnswer(answer);
 }
    @Override
    public boolean shouldSelectCell(EventObject anEvent) {
      if (!(anEvent instanceof MouseEvent)) return true;
      MouseEvent e = (MouseEvent) anEvent;

      int row = PositionUtil.getRowIndex(e.getPoint(), getRowHeight());
      if (row > getRowCount() - 1) {
        return false;
      }
      Point point = calcPoint4Graph(e.getPoint());
      Collection<? extends PrintElement> printElements =
          getVisibleGraph().getRowInfo(row).getPrintElements();
      PrintElement printElement = myGraphCellPainter.mouseOver(printElements, point.x, point.y);
      return printElement == null;
    }
    private void performAction(@NotNull MouseEvent e, @NotNull final GraphAction.Type actionType) {
      int row = PositionUtil.getRowIndex(e.getPoint(), getRowHeight());
      if (row > getRowCount() - 1) {
        return;
      }
      Point point = calcPoint4Graph(e.getPoint());
      Collection<? extends PrintElement> printElements =
          getVisibleGraph().getRowInfo(row).getPrintElements();
      PrintElement printElement = myGraphCellPainter.mouseOver(printElements, point.x, point.y);

      Selection previousSelection = getSelection();
      GraphAnswer<Integer> answer =
          getVisibleGraph()
              .getActionController()
              .performAction(new GraphAction.GraphActionImpl(printElement, actionType));
      handleAnswer(
          answer,
          actionType == GraphAction.Type.MOUSE_CLICK && printElement != null,
          previousSelection);
    }
Esempio n. 4
0
 @NotNull
 private Point calcPoint4Graph(@NotNull Point clickPoint) {
   return new Point(clickPoint.x - getXOffset(), PositionUtil.getYInsideRow(clickPoint));
 }