예제 #1
0
 /**
  * ******************************** Mouse Dragged
  *
  * @param e event
  */
 public void mouseDragged(MouseEvent e) {
   //	Nothing selected
   if (m_draggedNode == null || e.getSource() != m_draggedNode) {
     if (e.getSource() instanceof WFNode) {
       WFNode node = (WFNode) e.getSource();
       if (node.isEditable()) m_draggedNode = node;
       m_draggedStart = null;
     }
   }
   //	Move Node
   if (m_draggedNode != null) {
     m_dragged = true;
     if (m_draggedStart == null)
       m_draggedStart = SwingUtilities.convertPoint(m_draggedNode, e.getX(), e.getY(), this);
     //	If not converted to coordinate system of parent, it gets jumpy
     Point mousePosition = SwingUtilities.convertPoint(m_draggedNode, e.getX(), e.getY(), this);
     int xDelta = mousePosition.x - m_draggedStart.x;
     int yDelta = mousePosition.y - m_draggedStart.y;
     Point newLocation = m_draggedNode.getLocation();
     newLocation.x += xDelta;
     if (newLocation.x < 0) newLocation.x = 0;
     newLocation.y += yDelta;
     if (newLocation.y < 0) newLocation.y = 0;
     m_draggedNode.setLocation(newLocation.x, newLocation.y);
     //	log.fine("mouseDragged - " + m_draggedNode + " - " + e);
     //	log.fine("mouseDragged - Delta=" + xDelta + "/" + yDelta);
     m_draggedStart = mousePosition;
     invalidate();
     validate();
     repaint();
   }
 } //	mouseDragged
  /** @return the grid component that contains the given mouse ponit. */
  private GridComponent getComponent(MouseEvent e) {
    DesignGridOverlay overlay = (DesignGridOverlay) m_comp.getChildOverlay();
    Point local_pt =
        SwingUtilities.convertPoint((Component) e.getSource(), e.getPoint(), (Component) overlay);
    GridComponent cell = overlay.getCell(local_pt);
    if (cell == null) {
      DesignFormComponent parent = (DesignFormComponent) getParentForm(m_comp);
      if (parent != null) {
        DesignGridOverlay parentoverlay = (DesignGridOverlay) parent.getChildOverlay();
        local_pt =
            SwingUtilities.convertPoint(
                (Component) e.getSource(), e.getPoint(), (Component) parentoverlay);

        int y = local_pt.y;
        int x = local_pt.x;

        if (x >= m_comp.getCellX()
            && x <= m_comp.getCellX() + m_comp.getCellWidth()
            && y >= m_comp.getCellY()
            && y <= m_comp.getCellY() + m_comp.getCellHeight()) {
          cell = m_comp;
        }
      }
    }
    return cell;
  }
예제 #3
0
    @Override
    public void mousePressed(MouseEvent e) {
      draggedComponent = e.getComponent();
      lastLocation =
          SwingUtilities.convertPoint(draggedComponent, e.getPoint(), draggedComponent.getParent());

      draggedComponent1 = e.getComponent();
      lastLocation1 =
          SwingUtilities.convertPoint(
              draggedComponent1, e.getPoint(), draggedComponent1.getParent());
    }
  private int getComponentIndexAtPoint(Point p) {
    JComponent c = null;
    Point p2 = SwingUtilities.convertPoint(this, p, componentBox);
    Point p3 = SwingUtilities.convertPoint(componentBox, p, outerParentArea);
    if (outerParentArea.contains(p3))
      c =
          (JComponent)
              ComponentUtil.getChildAtLine(
                  componentBox, p2, getDirectionLayout().getDirection().isHorizontal());

    return layoutOrderList.indexOf(c);
  }
예제 #5
0
  private void pasteStack(BlockNode node) {
    //		====================>>>>>>>>>>>>>>>>>>>>>>>>>
    //		====================focus coming in>>>>>>>>>> TODO
    //		====================>>>>>>>>>>>>>>>>>>>>>>>>>
    if (node == null) {
      return;
    }
    WorkspaceWidget widget = null;
    Iterable<WorkspaceWidget> widgets = null;
    Point spot = null;
    if (invalidBlockID(focusManager.getFocusBlockID())) {
      // canvas has focus
      Point location =
          SwingUtilities.convertPoint(
              this.blockCanvas.getCanvas(), this.focusManager.getCanvasPoint(), workspace);
      widget = workspace.getWidgetAt(location);
      spot =
          SwingUtilities.convertPoint(
              this.blockCanvas.getCanvas(),
              this.focusManager.getCanvasPoint(),
              widget.getJComponent());
    } else {
      RenderableBlock focusRenderable =
          workspace.getEnv().getRenderableBlock(focusManager.getFocusBlockID());
      widget = focusRenderable.getParentWidget();
      spot = focusRenderable.getLocation();
    }

    if (widget == null) {
      // TODO: To be examined and fixed, occurs on macs
      JOptionPane.showMessageDialog(
          frame, "Please click somewhere on the canvas first.", "Error", JOptionPane.PLAIN_MESSAGE);
      // throw new RuntimeException("Why are we adding a block to a null widget?");
    } else {
      // checks to see if the copied block still exists
      if (BlockUtilities.blockExists(workspace, node)) {
        // create mirror block and mirror childrens
        spot.translate(10, 10);
        RenderableBlock mirror = BlockUtilities.makeRenderable(workspace, node, widget);
        mirror.setLocation(spot);
        mirror.moveConnectedBlocks(); // make sure the childrens are placed correctly
      } else {
        // TODO: future version, allow them to paste
        JOptionPane.showMessageDialog(
            frame,
            "You cannot paste blocks that are currently NOT on the canvas."
                + "\nThis function will be available in a future version.\n",
            "Error",
            JOptionPane.PLAIN_MESSAGE);
      }
    }
  }
  public boolean startDragging(MouseEvent mouseEvent) {

    // Get the mouse position and the component of the mouse event.
    Component mouseComponent = (Component) mouseEvent.getSource();
    int x = mouseEvent.getX();
    int y = mouseEvent.getY();

    // Reset the fields.
    reset();

    // Initialize the fields for docking.

    // Get the origin dock.
    originDock = (LeafDock) SwingUtilities.getAncestorOfClass(LeafDock.class, mouseComponent);
    if (originDock != null) {
      // Control that the dragged dockable belongs to this dock.
      if (originDock.containsDockable(draggedDockable)) {
        // Calculate the dockable offset.
        dockableOffset.setLocation(x, y);
        dockableOffset =
            SwingUtilities.convertPoint(
                mouseComponent, dockableOffset, draggedDockable.getContent());

        // We could find a dockable for dragging.
        return true;
      }
    }

    // We could not find a dockable for dragging.
    return false;
  }
예제 #7
0
    public void mouseClicked(MouseEvent ev) {
      Window w = (Window) ev.getSource();
      Frame f = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else {
        return;
      }

      Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane());

      int state = f.getExtendedState();
      if (getTitlePane() != null && getTitlePane().contains(convertedPoint)) {
        if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
          if (f.isResizable()) {
            if ((state & Frame.MAXIMIZED_BOTH) != 0) {
              f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH);
            } else {
              f.setExtendedState(state | Frame.MAXIMIZED_BOTH);
            }
            return;
          }
        }
      }
    }
예제 #8
0
  /**
   * @param block
   * @requires block must be a valid block. That is, block may not be such that block == null ||
   *     block.getBlockID() == null || block.getBlockID() == Block.NULL || block.getBlockID() == -1
   *     || Block.getBlock(block.getBlockID()) == null ||
   *     Block.getBlock(block.getBlockID()).getGenusName() == null ||
   *     Block.getBlock(block.getBlockID()).getGenusName().length() == 0 ||
   *     Block.getBlock(block.getBlockID()).getBlockLabel() == null
   * @modifies Objects modified by this method is undefined
   * @effects The effects of this method is unknown
   */
  private void addBlock(RenderableBlock block) {
    // check invariant
    if (block == null
        || block.getBlockID() == null
        || block.getBlockID().equals(Block.NULL)
        || workspace.getEnv().getBlock(block.getBlockID()) == null
        || workspace.getEnv().getBlock(block.getBlockID()).getGenusName() == null
        || workspace.getEnv().getBlock(block.getBlockID()).getGenusName().length() == 0
        || workspace.getEnv().getBlock(block.getBlockID()).getBlockLabel() == null) {
      throw new RuntimeException(
          "Invariant Violated: may not pass an invalid instance of renderabel block");
    }

    // ignore default arguments
    block.ignoreDefaultArguments();
    this.blockCanvas.getCanvas().add(block, 0);
    block.setLocation(0, 0);
    Long parentBlockID = this.focusManager.getFocusBlockID();
    if (invalidBlockID(parentBlockID)) {
      new BlockDropAnimator(
          workspace,
          this.focusManager.getCanvasPoint(),
          block,
          workspace.getEnv().getRenderableBlock(parentBlockID));
    } else {
      RenderableBlock parentBlock = workspace.getEnv().getRenderableBlock(parentBlockID);
      new BlockDropAnimator(
          workspace,
          SwingUtilities.convertPoint(
              parentBlock, this.focusManager.getBlockPoint(), this.blockCanvas.getCanvas()),
          block,
          workspace.getEnv().getRenderableBlock(parentBlockID));
    }
    this.focusManager.setFocus(block.getBlockID());
  }
      @Override
      public void mouseDragged(MouseEvent e) {
        if (!myDragging) return;
        MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this);
        final ToolWindowAnchor anchor = myInfo.getAnchor();
        final Point point = event.getPoint();
        final Container windowPane = InternalDecorator.this.getParent();
        myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane);
        myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth());
        myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight());

        final Rectangle bounds = InternalDecorator.this.getBounds();
        if (anchor == ToolWindowAnchor.TOP) {
          InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.LEFT) {
          InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height);
        } else if (anchor == ToolWindowAnchor.BOTTOM) {
          InternalDecorator.this.setBounds(
              0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.RIGHT) {
          InternalDecorator.this.setBounds(
              myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height);
        }
        InternalDecorator.this.validate();
        e.consume();
      }
예제 #10
0
    private Point getPointRelativeToGlassPane(Point imagePoint) {

      Point glassPanePoint =
          SwingUtilities.convertPoint(GlassPanedImagePanel.this, imagePoint, glassPane);

      return glassPanePoint;
    }
예제 #11
0
  /** Changes the thumb position to the specified grid component */
  void update(GridComponent gc) {
    DesignerDragSource dds =
        (DesignerDragSource) JETARegistry.lookup(DesignerDragSource.COMPONENT_ID);
    if (dds != null && dds != this && dds.isDragging()) {
      return;
    }

    if (isPaintMargin() && !m_dragging && m_compsrc.isSelectionTool()) {
      m_gc = gc;
      if (gc != null) {
        GridView parentview = gc.getParentView();
        if (parentview == m_view) {
          m_gc = null;
        } else {
          if (parentview != null) {
            Insets insets = parentview.getInsets();
            int col_offset = gc.getColumn() + gc.getColumnSpan() - 1;

            Point pt =
                javax.swing.SwingUtilities.convertPoint(
                    parentview,
                    parentview.getColumnOrgX(col_offset)
                        + parentview.getColumnWidth(col_offset)
                        + insets.left,
                    0,
                    this);
            m_xpos = pt.x;
          }
        }
      }
      repaint();
    }
  }
예제 #12
0
    /**
     * Start the drag if the operation is ok. uses java.awt.datatransfer.StringSelection to transfer
     * the label's data
     *
     * @param e the event object
     */
    @Override
    public void dragGestureRecognized(DragGestureEvent e) {
      logger.info("dragGestureRecognized");

      // if the action is ok we go ahead
      // otherwise we punt
      if ((e.getDragAction() & dragAction) == 0) {
        return;
        // get the label's text and put it inside a Transferable
        // Transferable transferable = new StringSelection(
        // DragLabel.this.getText() );
      }

      Point p =
          SwingUtilities.convertPoint(e.getComponent(), e.getDragOrigin(), PaletteElementView.this);
      PaletteElementTransferable transferable = new PaletteElementTransferable(getDrawable(), p);

      try {
        // initial cursor, transferrable, dsource listener
        e.startDrag(DrawingPalette.dropKO, transferable, dsListener);
        logger.info("Starting drag for " + getGraphicalRepresentation());
        getDrawingView().captureDraggedNode(PaletteElementView.this, e);
      } catch (Exception idoe) {
        logger.warning("Unexpected exception " + idoe);
      }
    }
예제 #13
0
  /**
   * Show a tool tip.
   *
   * @param tipText the tool tip text
   * @param pt the pixel position over which to show the tip
   */
  public void showTip(String tipText, Point pt) {
    if (getRootPane() == null) return;
    // draw in glass pane to appear on top of other components
    if (glassPane == null) {
      getRootPane().setGlassPane(glassPane = new JPanel());
      glassPane.setOpaque(false);
      glassPane.setLayout(null); // will control layout manually
      glassPane.add(tip = new JToolTip());
      tipTimer =
          new Timer(
              TIP_DELAY,
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  glassPane.setVisible(false);
                }
              });
      tipTimer.setRepeats(false);
    }
    if (tipText == null) return;

    // set tip text to identify current origin of pannable view
    tip.setTipText(tipText);

    // position tip to appear at upper left corner of viewport
    tip.setLocation(SwingUtilities.convertPoint(this, pt, glassPane));
    tip.setSize(tip.getPreferredSize());

    // show glass pane (it contains tip)
    glassPane.setVisible(true);
    glassPane.repaint();

    // this timer will hide the glass pane after a short delay
    tipTimer.restart();
  }
  public void dragDraggableComponent(DraggableComponent component, Point p) {
    if (draggableComponentList.contains(component)) {
      component.drag(SwingUtilities.convertPoint(this, p, component.getComponent()));
    }

    // component.drag(SwingUtilities.convertPoint(this, p, component.getComponent()));
  }
예제 #15
0
  public static void showInfoTooltip(
      @NotNull final HighlightInfo info,
      final Editor editor,
      final int defaultOffset,
      final int currentWidth) {
    if (info.toolTip == null || info.getSeverity() == HighlightSeverity.INFORMATION) return;
    Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
    int endOffset = info.highlighter.getEndOffset();
    int startOffset = info.highlighter.getStartOffset();

    Point top = editor.logicalPositionToXY(editor.offsetToLogicalPosition(startOffset));
    Point bottom = editor.logicalPositionToXY(editor.offsetToLogicalPosition(endOffset));

    Point bestPoint = new Point(top.x, bottom.y + editor.getLineHeight());

    if (!visibleArea.contains(bestPoint)) {
      bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
    }

    Point p =
        SwingUtilities.convertPoint(
            editor.getContentComponent(),
            bestPoint,
            editor.getComponent().getRootPane().getLayeredPane());
    TooltipController.getInstance()
        .showTooltip(editor, p, info.toolTip, currentWidth, false, DAEMON_INFO_GROUP);
  }
예제 #16
0
    public void mousePressed(MouseEvent e) {
      dragType = 0;
      Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), getContentPane());
      /*if (p.y < 10){
        dragType |= DRAG_TOP;
      }
      if (p.x < 5){
        dragType |= DRAG_LEFT;
      }
      if (p.x > getWidth() - 5){
        dragType |= DRAG_RIGHT;
      }
      if (p.y > getHeight() - 5){
        dragType |= DRAG_BOTTOM;
      }*/
      if (p.y < title.getY() + title.getHeight()) {
        dragType |= DRAG_TOP;
      }
      if (p.x < left.getX() + left.getWidth()) {
        dragType |= DRAG_LEFT;
      }
      if (p.x >= right.getX()) { // getWidth() - 5){
        dragType |= DRAG_RIGHT;
      }
      if (p.y >= bottom.getY()) {
        dragType |= DRAG_BOTTOM;
      }

      lastPoint = e.getPoint();
      SwingUtilities.convertPointToScreen(lastPoint, e.getComponent());
    }
 /**
  * Overrides method from MouseWheelListener to ensure that the screen is scaled suitably when
  * zooming in and out. Method will capture the number of notches the mouse wheel was moved by, and
  * then invoke scaleScreen. Positive inputs (scroll down) decrease the scale of the screen, and
  * negative inputs (scroll up) increase it.
  */
 @Override
 public void mouseWheelMoved(MouseWheelEvent e) {
   Point mousePos =
       SwingUtilities.convertPoint(
           this, e.getPoint(), this); // get current mouse position relative to this pane
   int wheelMovedBy = e.getWheelRotation(); // number of notches moved in the mouse wheel
   scaleScreen(wheelMovedBy);
 }
예제 #18
0
  private void checkScroll(MouseEvent e) {
    Point temp =
        SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), scoreTC.getScorePanel());

    scrollRect.setLocation(temp);

    scoreTC.getScorePanel().scrollRectToVisible(scrollRect);
  }
 public void mouseReleased(final MouseEvent e) {
   if (e.isPopupTrigger()) {
     Point pt =
         SwingUtilities.convertPoint((Component) e.getSource(), e.getX(), e.getY(), frame);
     popup.show(frame, pt.x, pt.y);
     return;
   }
 }
예제 #20
0
  private Point getLocationInTabbedPanel(Component c, TabbedPanel tp) {
    Point l = SwingUtilities.convertPoint(c.getParent(), c.getLocation(), tp);
    Insets tpInsets = tp.getInsets();
    l.x -= tpInsets.left;
    l.y -= tpInsets.top;

    return l;
  }
  /** Display the forwards window history in a menu. */
  private void onShowForwardHistory() {

    UIScrollableMenu hist =
        new UIScrollableMenu(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.forwardHistory"),
            0); //$NON-NLS-1$

    Vector views = history.getForwardHistory();
    int currentIndex = history.getCurrentPosition();

    int count = views.size();
    if (count == 0) return;

    JMenuItem item = null;
    for (int i = 0; i < count; i++) {
      View view = (View) views.elementAt(i);
      item = new JMenuItem(view.getLabel());

      final View fview = view;
      final int fi = (currentIndex + 1) + i;
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              if (history.goToHistoryItem(fi)) oParent.addViewToDesktop(fview, fview.getLabel());
            }
          });

      hist.add(item);
    }

    JPopupMenu pop = hist.getPopupMenu();
    pop.pack();

    Point loc = pbShowForwardHistory.getLocation();
    Dimension size = pbShowForwardHistory.getSize();
    Dimension popsize = hist.getPreferredSize();
    Point finalP = SwingUtilities.convertPoint(tbrToolBar.getParent(), loc, oParent.getDesktop());

    int x = 0;
    int y = 0;
    if (oManager.getLeftToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x + size.width;
      y = finalP.y;
    } else if (oManager.getRightToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x - popsize.width;
      y = finalP.y;
    } else if (oManager.getTopToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y + size.width;
    } else if (oManager.getBottomToolBarController().containsBar(tbrToolBar)) {
      x = finalP.x;
      y = finalP.y - popsize.height;
    }

    hist.setPopupMenuVisible(true);
    pop.show(oParent.getDesktop(), x, y);
  }
  public Point getLocationOn(JComponent c) {
    Point location;
    if (isRealPopup()) {
      location = myPopup.getLocationOnScreen();
      SwingUtilities.convertPointFromScreen(location, c);
    } else {
      if (myCurrentIdeTooltip != null) {
        Point tipPoint = myCurrentIdeTooltip.getPoint();
        Component tipComponent = myCurrentIdeTooltip.getComponent();
        return SwingUtilities.convertPoint(tipComponent, tipPoint, c);
      } else {
        location =
            SwingUtilities.convertPoint(myComponent.getParent(), myComponent.getLocation(), c);
      }
    }

    return location;
  }
예제 #23
0
 /** @overrides WorkspaceWidget.blockDropped() */
 @Override
 public void blockDropped(RenderableBlock block) {
   // add to view at the correct location
   Component oldParent = block.getParent();
   block.setLocation(
       SwingUtilities.convertPoint(oldParent, block.getLocation(), this.pageJComponent));
   addBlock(block);
   this.pageJComponent.setComponentZOrder(block, 0);
   this.pageJComponent.revalidate();
 }
예제 #24
0
  /**
   * @param aEvent
   * @param aStartPoint
   */
  protected void handleZoomRegion(final MouseEvent aEvent, final Point aStartPoint) {
    // For now, disabled by default as it isn't 100% working yet...
    if (Boolean.FALSE.equals(Boolean.valueOf(System.getProperty("zoomregionenabled", "false")))) {
      return;
    }

    final JComponent source = (JComponent) aEvent.getComponent();
    final boolean dragging = (aEvent.getID() == MouseEvent.MOUSE_DRAGGED);

    final GhostGlassPane glassPane =
        (GhostGlassPane) SwingUtilities.getRootPane(source).getGlassPane();

    Rectangle viewRect;
    final JScrollPane scrollPane =
        SwingComponentUtils.getAncestorOfClass(JScrollPane.class, source);
    if (scrollPane != null) {
      final JViewport viewport = scrollPane.getViewport();
      viewRect = SwingUtilities.convertRectangle(viewport, viewport.getVisibleRect(), glassPane);
    } else {
      viewRect = SwingUtilities.convertRectangle(source, source.getVisibleRect(), glassPane);
    }

    final Point start = SwingUtilities.convertPoint(source, aStartPoint, glassPane);
    final Point current = SwingUtilities.convertPoint(source, aEvent.getPoint(), glassPane);

    if (dragging) {
      if (!glassPane.isVisible()) {
        glassPane.setVisible(true);
        glassPane.setRenderer(new RubberBandRenderer(), start, current, viewRect);
      } else {
        glassPane.updateRenderer(start, current, viewRect);
      }

      glassPane.repaintPartially();
    } else
    /* if ( !dragging ) */
    {
      // Fire off a signal to the zoom controller to do its job...
      this.controller.getZoomController().zoomRegion(aStartPoint, aEvent.getPoint());

      glassPane.setVisible(false);
    }
  }
예제 #25
0
  @Override
  public void mouseDragged(MouseEvent e) {

    Point point =
        SwingUtilities.convertPoint(
            (JComponent) e.getSource(), e.getPoint(), scoreTC.getScorePanel());

    scoreTC.getMarquee().setDragPoint(point);
    e.consume();
    checkScroll(e);
  }
예제 #26
0
  public static void paintComponentDecoration(
      final GuiEditor editor, final RadComponent component, final Graphics g) {
    // Collect selected components and paint decoration for non selected components
    final ArrayList<RadComponent> selection = new ArrayList<RadComponent>();
    final Rectangle layeredPaneRect = editor.getLayeredPane().getVisibleRect();
    FormEditingUtil.iterate(
        component,
        new FormEditingUtil.ComponentVisitor<RadComponent>() {
          public boolean visit(final RadComponent component) {
            if (!component.getDelegee().isShowing()) { // Skip invisible components
              return true;
            }
            final Shape oldClip = g.getClip();
            final RadContainer parent = component.getParent();
            if (parent != null) {
              final Point p =
                  SwingUtilities.convertPoint(
                      component.getDelegee(), 0, 0, editor.getLayeredPane());
              final Rectangle visibleRect =
                  layeredPaneRect.intersection(
                      new Rectangle(p.x, p.y, parent.getWidth(), parent.getHeight()));
              g.setClip(visibleRect);
            }
            if (component.isSelected()) { // we will paint selection later
              selection.add(component);
            } else {
              paintComponentBoundsImpl(editor, component, g);
            }
            paintGridOutline(editor, component, g);
            if (parent != null) {
              g.setClip(oldClip);
            }
            return true;
          }
        });

    // Let's paint decoration for selected components
    for (int i = selection.size() - 1; i >= 0; i--) {
      final Shape oldClip = g.getClip();
      final RadComponent c = selection.get(i);
      final RadContainer parent = c.getParent();
      if (parent != null) {
        final Point p = SwingUtilities.convertPoint(c.getDelegee(), 0, 0, editor.getLayeredPane());
        final Rectangle visibleRect =
            layeredPaneRect.intersection(
                new Rectangle(p.x, p.y, parent.getWidth(), parent.getHeight()));
        g.setClip(visibleRect);
      }
      paintComponentBoundsImpl(editor, c, g);
      if (parent != null) {
        g.setClip(oldClip);
      }
    }
  }
 public static void setRelativeBounds(
     @NotNull Component parent,
     @NotNull Rectangle bounds,
     @NotNull Component child,
     @NotNull Container validationParent) {
   validationParent.add(parent);
   parent.setBounds(bounds);
   parent.validate();
   child.setLocation(SwingUtilities.convertPoint(child, 0, 0, parent));
   validationParent.remove(parent);
 }
예제 #28
0
 /**
  * Reset location of this dialog and sync to its parent.
  *
  * @return true means refresh sucess, else failed
  * @exception IllegalArgumentException means parentCom or contentCom is null
  */
 public boolean refreshLocation() {
   if (parentCom != null && contentCom != null) {
     Point location = SwingUtilities.convertPoint(parentCom, getLocation(), this);
     setBounds(
         location.x + deltaX,
         (location.y + deltaY) - getPreferredSize().height,
         getPreferredSize().width,
         getPreferredSize().height);
     validate();
     return true;
   } else throw new IllegalArgumentException("parentCom or contentCom is null!");
 }
예제 #29
0
    private void redispatch(MouseEvent e) {

      setGlassPane(false);
      Point thePoint =
          SwingUtilities.convertPoint(myRootFrame.getGlassPane(), e.getX(), e.getY(), myRootFrame);
      Component theComponent =
          SwingUtilities.getDeepestComponentAt(myRootFrame, thePoint.x, thePoint.y);

      MouseEvent theEvt =
          SwingUtilities.convertMouseEvent(myRootFrame.getGlassPane(), e, theComponent);
      logger.debug(
          "Redispatching mouse event to component: " + theComponent.getClass() + e.isConsumed());
      theComponent.dispatchEvent(theEvt);

      Point theLocalPoint =
          SwingUtilities.convertPoint(myRootFrame.getGlassPane(), e.getX(), e.getY(), CPanel.this);
      if (contains(theLocalPoint))
        dispatchEvent(SwingUtilities.convertMouseEvent(myRootFrame.getGlassPane(), e, CPanel.this));

      setGlassPane(true);
    }
    private void setDispatchComponent(MouseEvent event) {
      // Get location
      Point point = event.getPoint();

      // Get editor component
      Component editorComponent = grid.getEditorComponent();

      // Get dispatchComponent
      Point editorPoint = SwingUtilities.convertPoint(grid, point, editorComponent);
      dispatchComponent =
          SwingUtilities.getDeepestComponentAt(editorComponent, editorPoint.x, editorPoint.y);
    }