示例#1
1
 public static void muovi(JComponent jc, int x, int y) {
   int inX = jc.getX();
   int inY = jc.getY();
   int spost = (Math.abs(x - inX) + Math.abs(y - inY)) / 3;
   if (spost != 0) {
     int spostX = (x - inX) / spost;
     int spostY = (y - inY) / spost;
     int restoX = 0;
     int restoY = 0;
     int nX, nY;
     for (int i = 0; i < spost; i++) {
       restoX = (x - inX + restoX) % spost;
       restoY = (y - inY + restoY) % spost;
       nX = jc.getX() + (spostX);
       nY = jc.getY() + (spostY);
       spostX = (x - inX + restoX) / spost;
       spostY = (y - inY + restoY) / spost;
       jc.setLocation(nX, nY);
       jc.repaint();
       try {
         Thread.sleep(1 + 1 / 2);
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
     jc.setLocation(x, y);
   }
 }
示例#2
0
  protected void createComponents(IWizardPage page) {

    headerPanel = new DialogHeaderPanel();
    updateHeaderPanel(page);

    JPanel headerContainer = new JPanel();
    headerContainer.setLayout(new BorderLayout());
    headerContainer.add(headerPanel, BorderLayout.CENTER);
    headerContainer.add(new JSeparator(SwingConstants.HORIZONTAL), BorderLayout.SOUTH);

    JComponent pageContents = page.createControls();

    final DialogButtonsPanel buttonsPanel = getButtonsPanel();

    JPanel bp = new JPanel();
    bp.setLayout(new BorderLayout());
    bp.add(new JSeparator(SwingConstants.HORIZONTAL), BorderLayout.NORTH);
    bp.add(buttonsPanel, BorderLayout.CENTER);

    this.setLayout(new BorderLayout());
    this.add(headerContainer, BorderLayout.NORTH);
    if (pageContents != null) {
      this.add(pageContents, BorderLayout.CENTER);
      pageContents.repaint();
      page.updateControls();
    }
    this.add(bp, BorderLayout.SOUTH);
  }
 public void refreshPanel() {
   criteriaListPanel.removeAll();
   criteriaList.clear();
   criteriaListPanel.revalidate();
   criteriaListPanel.repaint();
   setHeadersEnabled(false);
 }
示例#4
0
  private void refreshMenu() {
    if (menuItems != null && menuItems.length > 0) {
      firstIndex = Math.max(topFixedCount, firstIndex);
      firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);

      upItem.setEnabled(firstIndex > topFixedCount);
      downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);

      menu.removeAll();
      for (int i = 0; i < topFixedCount; i++) {
        menu.add(menuItems[i]);
      }
      if (topFixedCount > 0) {
        menu.addSeparator();
      }

      menu.add(upItem);
      for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
        menu.add(menuItems[i]);
      }
      menu.add(downItem);

      if (bottomFixedCount > 0) {
        menu.addSeparator();
      }
      for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
        menu.add(menuItems[i]);
      }

      JComponent parent = (JComponent) upItem.getParent();
      parent.revalidate();
      parent.repaint();
    }
  }
示例#5
0
 private void revalidateFilterLayout() {
   JComponent c = (JComponent) keyFilter.getParent();
   if (c != null) {
     c.revalidate();
     c.repaint();
   }
 }
示例#6
0
  /**
   * Adds the supplied collection of beans at the supplied index in the list of collections. If the
   * index is not supplied then the primary collection is set (i.e. index 0). Also adds the beans to
   * the supplied JComponent container (if not null)
   *
   * @param beanInstances a <code>Vector</code> value
   * @param container a <code>JComponent</code> value
   */
  public static void setBeanInstances(
      Vector<Object> beanInstances, JComponent container, Integer... tab) {
    removeAllBeansFromContainer(container, tab);

    if (container != null) {
      for (int i = 0; i < beanInstances.size(); i++) {
        Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent) bean);
        }
      }
      container.revalidate();
      container.repaint();
    }

    int index = 0;
    if (tab.length > 0) {
      index = tab[0].intValue();
    }

    if (index < TABBED_COMPONENTS.size()) {
      TABBED_COMPONENTS.set(index, beanInstances);
    }

    // COMPONENTS = beanInstances;
  }
示例#7
0
 @Override
 public void mouseMoved(MouseEvent e) {
   Point p = e.getPoint();
   if (line.ptSegDist(p) <= 1.0) {
     tipLabel.setText(tooltip);
   }
   parent.repaint();
 }
示例#8
0
 @Override
 public void mouseEntered(MouseEvent e) {
   highlighted = tagSet;
   Object source = e.getSource();
   if (source instanceof JComponent) {
     ((JComponent) source).repaint();
   }
   chart.repaint();
 }
 @Override
 public void setFilter(@NotNull VcsLogFilter filter) {
   ApplicationManager.getApplication().assertIsDispatchThread();
   if (filter instanceof VcsLogBranchFilter) {
     myBranchFilterModel.setFilter((VcsLogBranchFilter) filter);
     JComponent toolbar = myUi.getMainFrame().getToolbar();
     toolbar.revalidate();
     toolbar.repaint();
   }
 }
示例#10
0
  public void mouseDragged(java.awt.event.MouseEvent e) {
    if (!org.nlogo.awt.Mouse.hasButton1(e)) {
      return;
    }
    java.awt.Point p = e.getPoint();
    java.awt.Rectangle rect = this.getBounds();

    p.x += rect.x;
    p.y += rect.y;

    if (newWidget != null) {
      if (workspace.snapOn()) {
        startDragPoint.x = (startDragPoint.x / GRID_SNAP) * GRID_SNAP;
        startDragPoint.y = (startDragPoint.y / GRID_SNAP) * GRID_SNAP;
      }
      java.awt.Point p2 =
          restrictDrag(
              new java.awt.Point(e.getX() - startDragPoint.x, e.getY() - startDragPoint.y),
              newWidget);
      newWidget.setLocation(startDragPoint.x + p2.x, startDragPoint.y + p2.y);
    } else if (null != startDragPoint) {
      if (!glassPane.isVisible()) {
        glassPane.setBounds(0, 0, getWidth(), getHeight());
        glassPane.setVisible(true);
      }
      scrollRectToVisible(new java.awt.Rectangle(e.getX() - 20, e.getY() - 20, 40, 40));
      java.awt.Rectangle oldSelectionRect = selectionRect;
      int x = StrictMath.min(getWidth(), StrictMath.max(e.getX(), 0));
      int y = StrictMath.min(getHeight(), StrictMath.max(e.getY(), 0));
      selectionRect =
          new java.awt.Rectangle(
              StrictMath.min(startDragPoint.x, x),
              StrictMath.min(startDragPoint.y, y),
              StrictMath.abs(x - startDragPoint.x),
              StrictMath.abs(y - startDragPoint.y));
      selectWidgets(selectionRect);
      if (oldSelectionRect != null) {
        glassPane.repaint(oldSelectionRect);
      }
      glassPane.repaint(selectionRect);
    }
  }
示例#11
0
    @Override
    public void mouseMoved(MouseEvent e) {
      Point p = e.getPoint();
      Point l = node.getLocation();
      Dimension d = node.getSize();

      if (l.x <= p.x && l.y <= p.y && l.x + d.width >= p.x && l.y + d.height >= p.y) {
        tipLabel.setText(tooltip);
      }
      parent.repaint();
    }
示例#12
0
 @Override
 public void mouseExited(MouseEvent e) {
   if (tagSet.equals(highlighted)) {
     highlighted = null;
   }
   Object source = e.getSource();
   if (source instanceof JComponent) {
     ((JComponent) source).repaint();
   }
   chart.repaint();
 }
  public void updateLocation(JComponent container) {
    final Rectangle rec = container.getVisibleRect();

    final Dimension iconSize = getPreferredSize();

    final Rectangle newBounds =
        new Rectangle(rec.x + rec.width - iconSize.width, rec.y, iconSize.width, iconSize.height);
    if (!newBounds.equals(getBounds())) {
      setBounds(newBounds);
      container.repaint();
    }
  }
示例#14
0
  /**
   * Mensagem do fim de jogo.
   *
   * @param mensagem do fim do jogo.
   */
  public void mensagemFimJogo(String mensagem) {

    JOptionPane.showMessageDialog(
        this,
        mensagem,
        "*****@*****.**",
        JOptionPane.INFORMATION_MESSAGE,
        CarregaImagemUtil.createImageIcon(Global.IMG_DARLAN));
    fimDeJogo = true;
    super.enable(false);
    super.repaint();
  }
示例#15
0
  private void removeFromParent() {
    // Change visibility option
    opacity = 0f;

    // Remove file
    Container container = this.getParent();
    if (container != null && container instanceof JComponent) {
      JComponent parent = (JComponent) container;
      parent.remove(this);
      parent.revalidate();
      parent.repaint();
    }
  }
示例#16
0
  @Override
  protected void paintComponent(Graphics g) {
    // TODO Auto-generated method stub
    super.paintComponent(g);
    // g.drawLine(0, 300, 600, 50);
    g.setColor(Color.YELLOW);
    g.fillOval(x, 50, 500, 500);
    g.setColor(Color.WHITE);
    g.fillOval(150, 100, 100, 100);
    g.fillOval(350, 100, 100, 100);
    g.setColor(Color.BLUE);
    // g.fillOval(180, y, 50, 50);
    // g.fillOval(380, 100, 50, 50);
    g.setColor(Color.RED);
    g.fillArc(x3, 350, 350, 150, 180, 180);
    g.setColor(Color.MAGENTA);
    g.fillArc(x2, 350, 100, 200, 200, -200);
    g.setColor(Color.BLACK);

    g.setColor(Color.BLUE);
    g.fillOval(180, y, 50, h);
    g.fillOval(380, y, 50, h);
    y++;
    if (y == 150) {
      y = 100;
    }
    x--;
    if (x == 50) {
      x = 100;
    }
    x2--;
    if (x2 == 200) {
      x2 = 250;
    }
    h++;
    if (h == 50) {
      h = 0;
    }
    x3--;
    if (x3 == 100) {
      x3 = 150;
    }

    try {
      Thread.sleep(20);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    super.repaint();
  }
 @Override
 protected void repaint() {
   if (SwingUtilities.isEventDispatchThread()) {
     component.repaint();
   } else {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             component.repaint();
           }
         });
   }
 }
示例#18
0
 /** Constroi o tabuleiro 8x8 Casas */
 public TabuleiroGUI() {
   super.setSize(400, 400);
   casas = new CasaGUI[8][8];
   int controle = 0;
   for (int y = 0; y < 8; y++) {
     for (int x = 0; x < 8; x++) {
       if (x % 2 == controle) casas[x][y] = new CasaGUI(x, y, Color.WHITE);
       else casas[x][y] = new CasaGUI(x, y, Color.BLACK);
       add(casas[x][y]);
     }
     if (controle == 0) controle = 1;
     else controle = 0;
   }
   super.repaint();
 }
 /**
  * Selects the canvas at the specified index. If the index is out of bounds, perform no action.
  *
  * @param index - the index of the canvas to be viewed.
  * @requires none (INDEX DOES NOT HAVE TO BE WITHIN BOUNDS)
  */
 public void selectCanvas(int index) {
   if (index >= 0 && index < drawerCards.size()) {
     TabCard card = drawerCards.get(index);
     canvasPane.removeAll();
     canvasPane.add(card.getScroll());
     canvasPane.revalidate();
     canvasPane.repaint();
     for (TabCard otherCard : drawerCards) {
       otherCard.getButton().toggleSelected(false);
     }
     card.getButton().toggleSelected(true);
     this.selectedIndex = index;
     this.revalidate();
   }
 }
示例#20
0
  /**
   * Adds the component of a specific <tt>PluginComponent</tt> to the associated <tt>Container</tt>.
   *
   * @param c the <tt>PluginComponent</tt> which is to have its component added to the
   *     <tt>Container</tt> associated with this <tt>PluginContainer</tt>
   */
  private synchronized void addPluginComponent(PluginComponent c) {
    /*
     * Try to respect positionIndex of PluginComponent to some extent:
     * PluginComponents with positionIndex equal to 0 go at the beginning,
     * these with positionIndex equal to -1 follow them and then go these
     * with positionIndex greater than 0.
     */
    int cIndex = c.getPositionIndex();
    int index = -1;
    int i = 0;

    for (PluginComponent pluginComponent : pluginComponents) {
      if (pluginComponent.equals(c)) return;

      if (-1 == index) {
        int pluginComponentIndex = pluginComponent.getPositionIndex();

        if ((0 == cIndex) || (-1 == cIndex)) {
          if ((0 != pluginComponentIndex) && (cIndex != pluginComponentIndex)) index = i;
        } else if (cIndex < pluginComponentIndex) index = i;
      }

      i++;
    }

    int pluginComponentCount = pluginComponents.size();

    if (-1 == index) index = pluginComponents.size();

    /*
     * The container may have added Components of its own apart from the
     * ones this PluginContainer has added to it. Since the common case for
     * the additional Components is to have them appear at the beginning,
     * adjust the index so it gets correct in the common case.
     */
    int containerComponentCount = getComponentCount(container);

    addComponentToContainer(
        (Component) c.getComponent(),
        container,
        (containerComponentCount > pluginComponentCount)
            ? (index + (containerComponentCount - pluginComponentCount))
            : index);
    pluginComponents.add(index, c);

    container.revalidate();
    container.repaint();
  }
示例#21
0
  /**
   * Adds the supplied collection of beans to the end of the list of collections and to the
   * JComponent container (if not null)
   *
   * @param beanInstances the vector of bean instances to add
   * @param container
   */
  public static void addBeanInstances(Vector<Object> beanInstances, JComponent container) {
    // reset(container);

    if (container != null) {
      for (int i = 0; i < beanInstances.size(); i++) {
        Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent) bean);
        }
      }
      container.revalidate();
      container.repaint();
    }

    TABBED_COMPONENTS.add(beanInstances);
  }
示例#22
0
 void setSideTabsLimit(int sideTabsLimit) {
   if (mySideTabsLimit != sideTabsLimit) {
     mySideTabsLimit = sideTabsLimit;
     //      UIUtil.putClientProperty(myTabs, JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY,
     // mySideTabsLimit);
     myTabs.resetLayout(true);
     myTabs.doLayout();
     myTabs.repaint();
     TabInfo info = myTabs.getSelectedInfo();
     JComponent page = info != null ? info.getComponent() : null;
     if (page != null) {
       page.revalidate();
       page.repaint();
     }
   }
 }
 public synchronized void actionPerformed(ActionEvent e) {
   java.util.List<JComponent> componentsToRemove = null;
   java.util.List<Part> partsToRemove = null;
   for (JComponent component : animationStateMap.keySet()) {
     component.repaint();
     if (partsToRemove != null) {
       partsToRemove.clear();
     }
     Map<Part, AnimationState> map = animationStateMap.get(component);
     if (!component.isShowing() || map == null || map.size() == 0) {
       if (componentsToRemove == null) {
         componentsToRemove = new ArrayList<JComponent>();
       }
       componentsToRemove.add(component);
       continue;
     }
     for (Part part : map.keySet()) {
       if (map.get(part).isDone()) {
         if (partsToRemove == null) {
           partsToRemove = new ArrayList<Part>();
         }
         partsToRemove.add(part);
       }
     }
     if (partsToRemove != null) {
       if (partsToRemove.size() == map.size()) {
         // animation is done for the component
         if (componentsToRemove == null) {
           componentsToRemove = new ArrayList<JComponent>();
         }
         componentsToRemove.add(component);
       } else {
         for (Part part : partsToRemove) {
           map.remove(part);
         }
       }
     }
   }
   if (componentsToRemove != null) {
     for (JComponent component : componentsToRemove) {
       animationStateMap.remove(component);
     }
   }
   if (animationStateMap.size() == 0) {
     timer.stop();
   }
 }
 private void loadImage(Editor editor) {
   JComponent contentComponent = editor.getContentComponent();
   Border border = contentComponent.getBorder();
   if (border instanceof BackgroundImageBorder) {
     BackgroundImageBorder backgroundImageBorder = (BackgroundImageBorder) border;
     if (imagesList.size() > 1) {
       int i = random.nextInt(imagesList.size());
       ImageHolder imageHolder = imagesList.get(i);
       backgroundImageBorder.setImageHolder(imageHolder);
     } else if (imagesList.size() == 1) {
       backgroundImageBorder.setImageHolder(imagesList.get(0));
     } else {
       backgroundImageBorder.setImageHolder(null);
     }
     contentComponent.repaint();
   }
 }
示例#25
0
  /**
   * Creates preview for the device(video) in the video container.
   *
   * @param device the device
   * @param videoContainer the container
   * @throws IOException a problem accessing the device.
   * @throws MediaException a problem getting preview.
   */
  private static void createPreview(MediaDevice device, final JComponent videoContainer)
      throws IOException, MediaException {
    videoContainer.removeAll();

    videoContainer.revalidate();
    videoContainer.repaint();

    if (device == null) return;

    Component c =
        (Component)
            GuiActivator.getMediaService()
                .getVideoPreviewComponent(
                    device, videoContainer.getSize().width, videoContainer.getSize().height);

    videoContainer.add(c);
  }
 private static void repaintMnemonics(@NotNull Component focusOwner, boolean pressed) {
   if (pressed != myAltPressed) return;
   Window window = SwingUtilities.windowForComponent(focusOwner);
   if (window != null) {
     for (Component component : window.getComponents()) {
       if (component instanceof JComponent) {
         for (JComponent c :
             UIUtil.findComponentsOfType((JComponent) component, JComponent.class)) {
           if ((c instanceof JLabel && ((JLabel) c).getDisplayedMnemonicIndex() != -1)
               || (c instanceof AbstractButton
                   && ((AbstractButton) c).getDisplayedMnemonicIndex() != -1)) {
             c.repaint();
           }
         }
       }
     }
   }
 }
    public void setText(String txt) {
      text = txt;
      textlabel.repaint();
      if (!text.equals("")) {
        if (!isVisible()) {
          // Only setVisible if its needed
          // or the focus window will change
          toFront();
          setVisible(true);
        }

        // Give focus to capture window if its there
        if (cw.isVisible()) cw.requestFocus();
      } else {
        // Hide window
        setVisible(false);
      }
    }
  /**
   * Convenience method to handle mouse events.
   *
   * @param me the mouse event
   */
  private void dispatchEvent(MouseEvent me) {
    // determine whether border needs to be repainted, e.g. to reflect mouse-over changes
    boolean doRepaint = false;
    int id = me.getID();
    if ((id == MouseEvent.MOUSE_ENTERED) || (id == MouseEvent.MOUSE_MOVED) && !hovering) {
      if (rect.contains(me.getX(), me.getY())) {
        hovering = true;
        id = MouseEvent.MOUSE_ENTERED;
        doRepaint = true;
      }
    } else if ((id == MouseEvent.MOUSE_EXITED) || (id == MouseEvent.MOUSE_MOVED) && hovering) {
      if (!rect.contains(me.getX(), me.getY())) {
        hovering = false;
        id = MouseEvent.MOUSE_EXITED;
        doRepaint = true;
      }
    } else {
      if (rect.contains(me.getX(), me.getY())) {
        doRepaint = true;
      }
    }

    if (doRepaint) {
      // repaint the border's component
      Point pt = me.getPoint();
      pt.translate(-offset, 0);
      comp.setBounds(rect);
      comp.dispatchEvent(
          new MouseEvent(
              comp,
              id,
              me.getWhen(),
              me.getModifiers(),
              pt.x,
              pt.y,
              me.getClickCount(),
              me.isPopupTrigger(),
              me.getButton()));
      // repaint the enclosed container if invalidated
      if (!comp.isValid()) {
        container.repaint();
      }
    }
  }
 private void dispatchEvent(MouseEvent me) {
   if (rect != null && rect.contains(me.getX(), me.getY())) {
     Point pt = me.getPoint();
     pt.translate(-offset, 0);
     comp.setBounds(rect);
     comp.dispatchEvent(
         new MouseEvent(
             comp,
             me.getID(),
             me.getWhen(),
             me.getModifiers(),
             pt.x,
             pt.y,
             me.getClickCount(),
             me.isPopupTrigger(),
             me.getButton()));
     if (!comp.isValid()) container.repaint();
   }
 }
示例#30
0
  public static void appendBeans(JComponent container, Vector<Object> beans, int tab) {
    if (TABBED_COMPONENTS.size() > 0 && tab < TABBED_COMPONENTS.size()) {
      Vector<Object> components = TABBED_COMPONENTS.get(tab);
      //

      for (int i = 0; i < beans.size(); i++) {
        components.add(beans.get(i));
        if (container != null) {
          Object bean = ((BeanInstance) beans.elementAt(i)).getBean();
          if (Beans.isInstanceOf(bean, JComponent.class)) {
            container.add((JComponent) bean);
          }
        }
      }

      if (container != null) {
        container.revalidate();
        container.repaint();
      }
    }
  }