public void setLocation(int x, int y) {
   if (myViewBounds != null) {
     myViewBounds.setLocation(x, y);
   } else {
     setBounds(new Point(x, y), null);
   }
 }
  public void scrollToAttribute(Attribute a) {
    if (!a.getDescriptor().getConfig().equals(getConfig())) {
      logger.fine("Cannot scroll to attribute that isn't attached to this type of descriptor");
      return;
    }
    int rowIndex = getCurrentModel().getRowForDescriptor(a.getDescriptor());
    int colIndex = getCurrentModel().getColumnForAttribute(a);
    JScrollPane scrollPane = (JScrollPane) this.getComponent(0);
    JViewport viewport = (JViewport) scrollPane.getViewport();
    EnhancedTable table = (EnhancedTable) viewport.getView();

    // This rectangle is relative to the table where the
    // northwest corner of cell (0,0) is always (0,0).
    Rectangle rect = table.getCellRect(rowIndex, colIndex, true);

    // The location of the viewport relative to the table
    Point pt = viewport.getViewPosition();

    // Translate the cell location so that it is relative
    // to the view, assuming the northwest corner of the
    // view is (0,0)
    rect.setLocation(rect.x - pt.x, rect.y - pt.y);

    // Scroll the area into view
    viewport.scrollRectToVisible(rect);
  }
  public void addClient() {
    client =
        new Canvas() {
          public void paint(Graphics g) {
            super.paint(g);
          }
        };
    client.setBackground(new Color(30, 220, 40));
    clientCont.add(client);
    clientCont.validate();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    WindowIDProvider pid = (WindowIDProvider) acc.getPeer(client);
    log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
    Rectangle toFocusBounds = toFocus.getBounds();
    toFocusBounds.setLocation(toFocus.getLocationOnScreen());
    f.validate();

    // KDE doesn't accept clicks on title as activation - click below title
    Rectangle fbounds = f.getBounds();
    fbounds.y += f.getInsets().top;
    fbounds.height -= f.getInsets().top;

    Process proc =
        startClient(
            new Rectangle[] {
              fbounds,
              dummy.getBounds(),
              toFocusBounds,
              new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
              new Rectangle(10, 130, 20, 20)
            },
            pid.getWindow());
    new ClientWatcher(client, proc, clientCont).start();
  }
  /**
   * Put the properties of this component that shall be persisted at application exit to the
   * application {@link Config}
   */
  private void saveSettings() {
    GUI gUI = configuration.getgUI();

    Rectangle sizeAndLocation = gUI.getImageConflictViewer().getSizeAndLocation();

    sizeAndLocation.setLocation(this.getLocationOnScreen().x, this.getLocationOnScreen().y);
    sizeAndLocation.setSize(this.getSize().width, this.getSize().height);
  }
Exemple #5
0
  public void scrollToCellLocation(int rowIndex, int colIndex) {

    if (!(getParent() instanceof JViewport)) {
      return;
    }

    JViewport scrollPane = (JViewport) getParent();
    Rectangle rect = getCellRect(rowIndex, colIndex, true);
    Point p = scrollPane.getViewPosition();
    rect.setLocation(rect.x - p.x, rect.y - p.y);
    scrollPane.scrollRectToVisible(rect);
  }
 // Event forwarding. We need it if user does press-and-drag gesture for opening popup and
 // choosing item there.
 // It works in JComboBox, here we provide the same behavior
 private void dispatchEventToPopup(MouseEvent e) {
   if (myPopup != null && myPopup.isVisible()) {
     JComponent content = myPopup.getContent();
     Rectangle rectangle = content.getBounds();
     Point location = rectangle.getLocation();
     SwingUtilities.convertPointToScreen(location, content);
     Point eventPoint = e.getLocationOnScreen();
     rectangle.setLocation(location);
     if (rectangle.contains(eventPoint)) {
       MouseEvent event =
           SwingUtilities.convertMouseEvent(e.getComponent(), e, myPopup.getContent());
       Component component =
           SwingUtilities.getDeepestComponentAt(content, event.getX(), event.getY());
       if (component != null) component.dispatchEvent(event);
     }
   }
 }
 public void setVisible(boolean visible) {
   if (!visible && myView != null) {
     disposeAndUpdate(false);
   } else if (visible && myView == null) {
     Window owner = UIUtil.getWindow(myOwner);
     if (owner != null) {
       if (myHeavyWeight) {
         Window view = pop(owner);
         if (view == null) {
           view = new JWindow(owner);
           setPopupType(view);
         }
         setAlwaysOnTop(view, myAlwaysOnTop);
         setWindowFocusable(view, myWindowFocusable);
         setWindowShadow(view, myWindowShadow);
         myView = view;
       } else if (owner instanceof RootPaneContainer) {
         JLayeredPane parent = ((RootPaneContainer) owner).getLayeredPane();
         if (parent != null) {
           JPanel view = new JPanel(new BorderLayout());
           view.setVisible(false);
           parent.add(view, JLayeredPane.POPUP_LAYER, 0);
           myView = view;
         }
       }
     }
     if (myView != null) {
       myView.add(myContent);
       Component parent = myView instanceof Window ? null : myView.getParent();
       if (parent != null) {
         Point location = myViewBounds.getLocation();
         SwingUtilities.convertPointFromScreen(location, parent);
         myViewBounds.setLocation(location);
       }
       myView.setBackground(UIUtil.getLabelBackground());
       myView.setBounds(myViewBounds);
       myView.setVisible(true);
       myViewBounds = null;
     }
   }
 }
  public void scrollToColumnLocation(int colIndex) {
    JTable scrollTable = transposedSpreadsheetSubform.getScrollTable();
    scrollTable.setColumnSelectionInterval(colIndex, colIndex);

    JViewport scrollPane = transposedSpreadsheetSubform.getFrozenTable().getViewport();
    Rectangle rect = scrollTable.getCellRect(1, colIndex, true);
    Point p = scrollPane.getViewPosition();
    rect.setLocation(rect.x - p.x, rect.y - p.y);

    scrollPane.scrollRectToVisible(rect);

    Map<Integer, Color> columnToColor = new HashMap<Integer, Color>();
    columnToColor.put(colIndex, new Color(28, 117, 188, 70));

    transposedSpreadsheetSubform.changeTableRenderer(
        transposedSpreadsheetSubform.getScrollTable(),
        new SubFormCellRenderer(
            UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, null, columnToColor));

    transposedSpreadsheetSubform.validate();
    transposedSpreadsheetSubform.repaint();
  }
  public void paint(Graphics g) {
    // int numDoors=0;
    int rX = player.getRelativeX();
    int rY = player.getRelativeY();
    boolean notInBuilding = true;
    bufferGraphics.clearRect(0, 0, dim.width, dim.width);
    bufferGraphics.setColor(Color.WHITE);
    r2.setLocation(20 + rX, 20 + rY);

    // Iterator<Objects>  iterator1 = entities.iterator();//size is the last index, therefore it
    // starts at the end
    // while(iterator1.hasNext()){
    // iterator1.next().update(rX, rY);
    // bufferGraphics.drawImage(iterator1.next().image, iterator1.next().blockX+rX,
    // iterator1.next().blockX+rY, null);
    // }
    for (int x = 0; x < buildings.size(); x++) {
      buildings.get(x).update(rX, rY);
      player.onDoor(player.r, buildings.get(x).door);
      player.collideOn(player.r, buildings.get(x));
      if (player.inHouse(player.r, buildings.get(x).inside)) {
        notInBuilding = false;
      }
      // if(notInBuilding){
      // bufferGraphics.drawImage(buildings.get(x).image,
      // buildings.get(x).blockX+rX,buildings.get(x).blockY+rY, null);
      // }else{
      // bufferGraphics.drawImage(buildings.get(x).innerImage,
      // buildings.get(x).blockX+rX,buildings.get(x).blockY+rY, null);
      // }

      // bufferGraphics.fillRect(entities.get(x).bounds.x, entities.get(x).bounds.y,
      // entities.get(x).bounds.width, entities.get(x).bounds.height);
    }

    bufferGraphics.setFont(new Font("Arial", Font.PLAIN, 20));
    // String m1 = new Boolean(player.canMove('w')).toString();
    bufferGraphics.drawString(message, 0, 170);
    // bufferGraphics.fillRect(r2.x, r2.y, r2.width, r2.height);
    // player.collideOn(player.r, r2);
    // ***Image log1 = new ImageIcon(getClass().getResource("logTest.png")).getImage();
    // ***bufferGraphics.drawImage(log1, (int)r2.getX(), (int)r2.getY(), null);
    // bufferGraphics.drawLine((int)player.N.getX1(), (int)player.N.getY1(), (int)player.N.getX2(),
    // (int)player.N.getY2());
    // bufferGraphics.drawLine((int)player.E.getX1(), (int)player.E.getY1(), (int)player.E.getX2(),
    // (int)player.E.getY2());
    // bufferGraphics.drawLine((int)player.S.getX1(), (int)player.S.getY1(), (int)player.S.getX2(),
    // (int)player.S.getY2());
    // bufferGraphics.drawLine((int)player.W.getX1(), (int)player.W.getY1(), (int)player.W.getX2(),
    // (int)player.W.getY2());
    // bufferGraphics.setColor(Color.RED);
    // bufferGraphics.drawLine((int)player.NI.getX1(), (int)player.NI.getY1(),
    // (int)player.NI.getX2(), (int)player.NI.getY2());
    // bufferGraphics.drawLine((int)player.EI.getX1(), (int)player.EI.getY1(),
    // (int)player.EI.getX2(), (int)player.EI.getY2());
    // bufferGraphics.drawLine((int)player.SI.getX1(), (int)player.SI.getY1(),
    // (int)player.SI.getX2(), (int)player.SI.getY2());
    // bufferGraphics.drawLine((int)player.WI.getX1(), (int)player.WI.getY1(),
    // (int)player.WI.getX2(), (int)player.WI.getY2());
    if (notInBuilding) {
      Image thebg = new ImageIcon(getClass().getResource("grassbackingdev.png")).getImage();
      bufferGraphics.drawImage(thebg, 0 + rX, 0 + rY, null);
    }

    player.update();
    int setX = Math.abs(player.relativeX);
    int setY = Math.abs(player.relativeY);
    if (player.relativeX > 0) {
      setX = -setX;
    }
    if (player.relativeY > 0) {
      setY = -setY;
    }

    if (notInBuilding) {
      for (int x = 0; x < entities.size(); x++) {
        entities.get(x).update(rX, rY);
        bufferGraphics.drawImage(
            entities.get(x).image, entities.get(x).blockX + rX, entities.get(x).blockY + rY, null);
        player.collideOn(player.r, entities.get(x));
        if (entities.get(x).health <= 0) {
          if (entities.get(x).material == "Wood") wood += entities.get(x).matsReturn;
          if (entities.get(x).material == "Stone") stone += entities.get(x).matsReturn;
          entities.remove(x);
        }
        // bufferGraphics.fillRect(entities.get(x).bounds.x, entities.get(x).bounds.y,
        // entities.get(x).bounds.width, entities.get(x).bounds.height);
      }
    }
    for (int x = 0; x < buildings.size(); x++) {
      if (notInBuilding) {
        bufferGraphics.drawImage(
            buildings.get(x).image,
            buildings.get(x).blockX + rX,
            buildings.get(x).blockY + rY,
            null);
      } else {
        bufferGraphics.drawImage(
            buildings.get(x).innerImage,
            buildings.get(x).blockX + rX,
            buildings.get(x).blockY + rY,
            null);
      }
    }
    if (notInBuilding) {
      for (int x = 0; x < npcArray.size(); x++) {

        for (int e = 0; e < entities.size(); e++) {
          npcArray.get(x).detectEntities(entities.get(e));
          if (entities.get(e).health <= 0) {
            entities.remove(e);
          }
        }
        npcArray.get(x).update(rX, rY, setX + 92, setY + 82);
        bufferGraphics.drawImage(
            npcArray.get(x).graphic, npcArray.get(x).npcX + rX, npcArray.get(x).npcY + rY, null);
        if (npcArray.get(x).isDead()) {
          npcArray.remove(x);
        } else if (npcArray.get(x).hitBox.intersects(player.r)) {
          player.health -= 25;
          npcArray.remove(x);
        }
      }
    }
    for (int x = 0; x < playerAttack.size(); x++) {
      playerAttack.get(x).update(rX, rY);
      bufferGraphics.drawImage(
          playerAttack.get(x).graphic,
          playerAttack.get(x).currentX + rX,
          playerAttack.get(x).currentY + rY,
          null);
      for (int y = 0; y < npcArray.size(); y++) {
        if (playerAttack.get(x).hitBox.intersects(npcArray.get(y).hitBox)) {
          npcArray.get(y).health -= 25;
          playerAttack.get(x).hasHit = true;
        }
      }
      if (playerAttack.get(x).isDead()) {
        playerAttack.remove(x);
      }
    }

    player.notOnDoor = true;
    if (player.moving) {
      bufferGraphics.drawImage(
          player.getImage().getImage(), player.getCharx(), player.getChary(), null); // TODO
    } else {
      bufferGraphics.drawImage(player.getIdle(), player.getCharx(), player.getChary(), null);
    }
    if (Ghosting) {
      if (player.face == 1) {
        bufferGraphics.drawImage(player.getResource(resource), 104, 87, null); // EAST
      }
      if (player.face == 2) {
        bufferGraphics.drawImage(player.getResource(resource), 94, 106, null); // SOUTH*94,106
      }
      if (player.face == 3) {
        bufferGraphics.drawImage(player.getResource(resource), 84, 87, null); // WEST84,87
      }
      if (player.face == 4) {
        bufferGraphics.drawImage(player.getResource(resource), 94, 75, null); // NORTH94,75
      }
    }
    if (player.health <= 0) {
      bufferGraphics.drawString("You are dead", 10, 90);
      stop();
    }
    bufferGraphics.setFont(new Font("Arial", Font.PLAIN, 9));
    bufferGraphics.setColor(new Color(160, 82, 45));
    bufferGraphics.fillRect(0, 2, 8, 8);
    bufferGraphics.setColor(new Color(105, 105, 105));
    bufferGraphics.fillRect(0, 12, 8, 8);
    bufferGraphics.drawImage(statusBar, 0, 22, null);
    bufferGraphics.setColor(Color.WHITE);
    bufferGraphics.drawString(String.format("%d", wood), 18, 10);
    bufferGraphics.drawString(String.format("%d", stone), 18, 20);
    bufferGraphics.drawString(String.format("%d", player.health), 18, 30);
    // bufferGraphics.fillRect((int)player.r.getX(), (int)player.r.getY(),
    // (int)player.r.getWidth(),(int)player.r.getHeight());
    // bufferGraphics.fillRect(player.r.x, player.r.x, player.r.width, player.r.height);
    g.drawImage(offScreen, 0, 0, this);
    // if(drawConsole){
    // message = String.format("wood: %d", wood);
    // }

  }
 public void scrollRects() {
   for (Rectangle i : rectList) {
     i.setLocation((int) (i.getX()), (int) (i.getY() + (int) (player1.getVelocity() * 0.3)));
   }
 }