/**
   * <code>getLinkPointFromPoint</code> Return a point on the edge of or inside the ellipse,
   * rectangle, or diamond rather than a point on the port itself
   *
   * @param x - <code>int</code> -
   * @param y - <code>int</code> -
   * @param p - <code>Point</code> -
   * @return - <code>Point</code> -
   */
  public Point getLinkPointFromPoint(int x, int y, Point p) {
    BasicNode node = getNode();
    JGoDrawable obj = node.getDrawable();
    Rectangle rect = obj.getBoundingRect();
    int a = rect.width / 2;
    int b = rect.height / 2;
    int cx = getLeft() + getWidth() / 2;
    int cy = getTop() + getHeight() / 2;

    if (p == null) {
      p = new Point();
    }
    p.x = x;
    p.y = y;
    // if (x,y) is inside the object, just return it instead of finding the edge intersection
    if (!obj.isPointInObj(p)) {
      if (node.isRectangular()) {
        JGoRectangle.getNearestIntersectionPoint(
            rect.x, rect.y, rect.width, rect.height, x, y, cx, cy, p);
      }
      if (node instanceof ConstraintNode) {
        ((Diamond) ((ConstraintNode) node).getDrawable())
            .getNearestIntersectionPoint(x, y, cx, cy, p);
      } else if (node instanceof ParamNode) {
        ((Diamond) ((ParamNode) node).getDrawable()).getNearestIntersectionPoint(x, y, cx, cy, p);
      } else {
        JGoEllipse.getNearestIntersectionPoint(rect.x, rect.y, rect.width, rect.height, x, y, p);
      }
    }
    return p;
  } // end getLinkPointFromPoint
Exemplo n.º 2
0
  public void mousePressed(java.awt.event.MouseEvent e) {
    if (e.isPopupTrigger()) {
      doPopup(e);
      return;
    }
    if (!org.nlogo.awt.Mouse.hasButton1(e)) {
      return;
    }

    // this is so the user can use action keys to control buttons
    // - ST 8/6/04,8/31/04
    this.requestFocus();

    java.awt.Point p = e.getPoint();
    java.awt.Rectangle rect = this.getBounds();

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

    if (!rect.contains(p)) {
      return;
    }
    unselectWidgets();
    startDragPoint = e.getPoint();
    if (widgetCreator == null) {
      return;
    }
    Widget widget = widgetCreator.getWidget();
    if (widget == null) {
      return;
    }
    addWidget(widget, e.getX(), e.getY(), true, false);
    revalidate();
  }
Exemplo n.º 3
0
  public void displayInit(Point pickPoint) {
    gl.glShadeModel(GL.GL_SMOOTH);

    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();

    if (pickPoint != null) {
      int[] vp = new int[4];
      gl.glGetIntegerv(GL.GL_VIEWPORT, vp, 0);
      GLU glu = new GLU();
      int px = (int) pickPoint.getX();
      int py = (int) (vp[3] - pickPoint.getY());
      glu.gluPickMatrix(px, py, 1e-2, 1e-2, vp, 0);
    }

    gl.glOrtho(0, bounds.getWidth(), 0, bounds.getHeight(), .1, depth);

    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glLoadIdentity();

    glu.gluLookAt(0, 0, depth - 0.1, 0, 0, 0, 0, 1, 0);

    gl.glInitNames();
    gl.glPushName(-1);
  }
 public boolean mouseOnButton(MouseEvent event) {
   Point pt = event.getPoint();
   if (pt.getX() >= button.getX() && pt.getX() <= button.getX() + button.getWidth()) {
     return true;
   }
   return false;
 }
Exemplo n.º 5
0
 private void drawTextToImage() {
   Graphics g = image.getGraphics();
   g.setFont(textFont);
   g.setColor(getMainFrame().getColorBoxForeground());
   g.drawString(text, (int) (start.getX() / scale), (int) (start.getY() / scale));
   repaint();
 }
Exemplo n.º 6
0
  Point pack(int s) {
    if (s > w) return null;
    Point ret = new Point(0, 0);
    for (int y = 0; y < arr.size() - s + 1; y++) {
      for (int x = 0; x < w - s + 1; x++) {

        boolean fits = true;
        packLoop:
        for (int i = 0; i < s; i++) {
          for (int j = 0; j < s; j++) {
            if (arr.get(y + i)[x + j]) {
              fits = false;
              break packLoop;
            }
          }
        }
        if (fits) {
          for (int i = 0; i < s; i++) {
            for (int j = 0; j < s; j++) {
              arr.get(y + i)[x + j] = true;
            }
          }
          ret.x = x;
          ret.y = y;
          return ret;
        }
      }
    }
    int asize = arr.size() + 2;
    for (int i = 0; i < asize; i++) arr.add(new boolean[w]);

    return pack(s);
  }
Exemplo n.º 7
0
  /**
   * putWordInSlot()
   *
   * <p>Puts each letter from the word it's passed into the slot it's passed, and marks the word
   * USED. Also increments the positions in the letterUsage array corresponding to the slot to
   * indicate that one more word is now using these letters.
   */
  private void putWordInSlot(CrosswordWord w, CrosswordSpace slot) {
    Point position = new Point(slot.getStart());

    for (int i = 0; i < slot.getLength(); i++) {

      // Put each letter from the word into this slot of
      // the puzzle:

      puzzle[position.x][position.y] = w.getWord().charAt(i);

      // Record the fact that one more word is now using the
      // letter at this position:

      letterUsage[position.x][position.y]++;

      // Advance to the next position in the slot:

      position.x += slot.getDirection().x;
      position.y += slot.getDirection().y;
    }

    // Mark the word as USED:

    w.setUsed(true);
  }
Exemplo n.º 8
0
  public static Point CenterPoint(Dimension size) {
    Point loc_p = new Point();

    loc_p.setLocation(size.getWidth() / 2, size.getHeight() / 2);

    return loc_p;
  }
Exemplo n.º 9
0
  /**
   * Determines which cell in the layout grid contains the point specified by <code>(x,&nbsp;y)
   * </code>. Each cell is identified by its column index (ranging from 0 to the number of columns
   * minus 1) and its row index (ranging from 0 to the number of rows minus 1).
   *
   * <p>If the <code>(x,&nbsp;y)</code> point lies outside the grid, the following rules are used.
   * The column index is returned as zero if <code>x</code> lies to the left of the layout for a
   * left-to-right container or to the right of the layout for a right-to-left container. The column
   * index is returned as the number of columns if <code>x</code> lies to the right of the layout in
   * a left-to-right container or to the left in a right-to-left container. The row index is
   * returned as zero if <code>y</code> lies above the layout, and as the number of rows if <code>y
   * </code> lies below the layout. The orientation of a container is determined by its <code>
   * ComponentOrientation</code> property.
   *
   * @param x the <i>x</i> coordinate of a point
   * @param y the <i>y</i> coordinate of a point
   * @return an ordered pair of indexes that indicate which cell in the layout grid contains the
   *     point (<i>x</i>,&nbsp;<i>y</i>).
   * @see java.awt.ComponentOrientation
   * @since JDK1.1
   */
  public Point location(int x, int y) {
    Point loc = new Point(0, 0);
    int i, d;

    if (layoutInfo == null) return loc;

    d = layoutInfo.startx;
    if (!rightToLeft) {
      for (i = 0; i < layoutInfo.width; i++) {
        d += layoutInfo.minWidth[i];
        if (d > x) break;
      }
    } else {
      for (i = layoutInfo.width - 1; i >= 0; i--) {
        if (d > x) break;
        d += layoutInfo.minWidth[i];
      }
      i++;
    }
    loc.x = i;

    d = layoutInfo.starty;
    for (i = 0; i < layoutInfo.height; i++) {
      d += layoutInfo.minHeight[i];
      if (d > y) break;
    }
    loc.y = i;

    return loc;
  }
Exemplo n.º 10
0
 /**
  * Function move moves head of the snake in given direction. Direction and size of of map must be
  * provided
  *
  * @param direct directions of next move
  * @param mapSize size of game board
  * @return true-move was made, false-move cannot be made
  */
 public boolean move(Directions direct, int mapSize) {
   ListIterator<Point> it = this.body.listIterator();
   Point tmp = it.next();
   switch (direct) {
     case UP:
       if (tmp.getY() != 0) {
         this.moveUp();
         return true;
       } else return false;
     case DOWN:
       if (tmp.getY() != mapSize - 1) {
         moveDown();
         return true;
       } else return false;
     case RIGHT:
       if (tmp.getX() != mapSize - 1) {
         moveRight();
         return true;
       } else return false;
     case LEFT:
       if (tmp.getX() != 0) {
         moveLeft();
         return true;
       } else return false;
     default:
       return false;
   }
 }
Exemplo n.º 11
0
  /**
   * Spusti se pri zmacknuti tlacitka. Pokud je pod mysi obraz figury, zjisti, zda se muze pohnout
   * (pokud ano, upravi ho pro tahnuti, nastavi ho do figLabel) a zobrazi kontextovou napovedu.
   */
  private void eCatcherMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_eCatcherMousePressed
    if (figLabel != null || finished) {
      return;
    }
    BoardSquare bsquare = (BoardSquare) eCatcher.getComponentAt(evt.getPoint());

    JPanel fsquare = (JPanel) figurePan.getComponent(bsquare.getIndex());
    sourceBSquare = bsquare;
    Point defLocation = fsquare.getLocation();
    xAdjustment = (int) defLocation.getX() - evt.getX();
    yAdjustment = (int) defLocation.getY() - evt.getY();
    if (fsquare.getComponentCount() == 0) {
      return;
    }
    figLabel = (JLabel) fsquare.getComponent(0);

    setFocus(gui.getFocus(bsquare.getColumn(), bsquare.getRow()));
    if (!gui.canMove(bsquare.getColumn(), bsquare.getRow())) {
      figLabel = null;
      return;
    }
    fsquare.remove(figLabel);
    boardPane.add(figLabel, 0);
    figLabel.setLocation(evt.getX() + xAdjustment, evt.getY() + yAdjustment);
    figLabel.setSize(figLabel.getWidth(), figLabel.getHeight());
  } // GEN-LAST:event_eCatcherMousePressed
Exemplo n.º 12
0
  @Override
  public void mouseClicked(java.awt.event.MouseEvent e) {
    Point cellLocation = this.mGrid.getCells()[0][0].getLocation();
    int mouseX = e.getX() - (int) cellLocation.getX();
    int mouseY = e.getY() - (int) cellLocation.getY();

    this.mGrid.getCells()[mouseX / 12][mouseY / 12].setState(this.mCellTemp.getState());
    if (this.mGrid.getCells()[mouseX / 12][mouseY / 12].getState() == 0) {
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].setBackground(Color.white);
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].repaint();
    } else if (this.mGrid.getCells()[mouseX / 12][mouseY / 12].getState() == 1) {
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].setBackground(Color.decode("#92d050"));
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].repaint();
    } else if (this.mGrid.getCells()[mouseX / 12][mouseY / 12].getState() == 2) {
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].setBackground(Color.decode("#339933"));
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].repaint();
    } else if (this.mGrid.getCells()[mouseX / 12][mouseY / 12].getState() == 4) {
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].setBackground(Color.decode("#004800"));
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].repaint();
    } else if (this.mGrid.getCells()[mouseX / 12][mouseY / 12].getState() == 5) {
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].setBackground(Color.decode("#ff0000"));
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].repaint();
    } else if (this.mGrid.getCells()[mouseX / 12][mouseY / 12].getState() == 7) {
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].setBackground(Color.decode("#7030a0"));
      this.mGrid.getCells()[mouseX / 12][mouseY / 12].repaint();
    }
  }
Exemplo n.º 13
0
  /**
   * Calculates location of caret and displays the suggestion popup at the location.
   *
   * @param listModel
   * @param subWord
   */
  protected void showSuggestion(DefaultListModel<CompletionCandidate> listModel, String subWord) {
    // new Exception(System.currentTimeMillis() + "").printStackTrace(System.out);
    hideSuggestion();

    if (listModel.size() == 0) {
      Messages.log("TextArea: No suggestions to show.");

    } else {
      int position = getCaretPosition();
      Point location = new Point();
      try {
        location.x = offsetToX(getCaretLine(), position - getLineStartOffset(getCaretLine()));
        location.y =
            lineToY(getCaretLine())
                + getPainter().getFontMetrics().getHeight()
                + getPainter().getFontMetrics().getDescent();
        // log("TA position: " + location);
      } catch (Exception e2) {
        e2.printStackTrace();
        return;
      }

      suggestion = new CompletionPanel(this, position, subWord, listModel, location, editor);
      requestFocusInWindow();
    }
  }
Exemplo n.º 14
0
  protected void applyOffsetAmount(Point p1, Point p2, int offset, Point res) {
    // slope of the line we're finding the normal to
    // is slope, and the normal is the negative reciprocal
    // slope is (p1.y - p2.y) / (p1.x - p2.x)
    // so recip is - (p1.x - p2.x) / (p1.y - p2.y)
    int recipnumerator = (p1.x - p2.x) * -1;
    int recipdenominator = (p1.y - p2.y);

    if (recipdenominator == 0 && recipnumerator == 0) return;

    // find the point offset on the line that gives a
    // correct offset

    double len = Math.sqrt(recipnumerator * recipnumerator + recipdenominator * recipdenominator);
    int dx = (int) ((recipdenominator * offset) / len);
    int dy = (int) ((recipnumerator * offset) / len);

    res.x += Math.abs(dx);
    res.y -= Math.abs(dy);

    int width = itemFig.getWidth() / 2;

    if (recipnumerator != 0) {
      double slope = (double) recipdenominator / (double) recipnumerator;

      double factor = tanh(slope);
      res.x += (Math.abs(factor) * width);
    } else {
      res.x += width;
    }
  }
Exemplo n.º 15
0
  private void showSliderMenu() {
    Point location = new Point(getX(), getY() + getHeight());

    SwingUtilities.convertPointToScreen(location, InputVolumeControlButton.this.getParent());

    if (isFullScreen()) {
      location.setLocation(
          location.getX(),
          location.getY() - sliderMenu.getPreferredSize().getHeight() - getHeight());
    }

    sliderMenu.setLocation(location);

    sliderMenu.addPopupMenuListener(
        new PopupMenuListener() {
          public void popupMenuWillBecomeVisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = true;
          }

          public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = false;
          }

          public void popupMenuCanceled(PopupMenuEvent ev) {}
        });

    sliderMenu.setVisible(!sliderMenu.isVisible());
  }
Exemplo n.º 16
0
    private void showJPopupMenu(MouseEvent e) {
      try {
        if (e.isPopupTrigger() && menu != null) {
          if (window == null) {

            if (isWindows) {
              window = new JDialog((Frame) null);
              ((JDialog) window).setUndecorated(true);
            } else {
              window = new JWindow((Frame) null);
            }
            window.setAlwaysOnTop(true);
            Dimension size = menu.getPreferredSize();

            Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
            if (e.getY() > centerPoint.getY()) window.setLocation(e.getX(), e.getY() - size.height);
            else window.setLocation(e.getX(), e.getY());

            window.setVisible(true);

            menu.show(((RootPaneContainer) window).getContentPane(), 0, 0);

            // popup works only for focused windows
            window.toFront();
          }
        }
      } catch (Exception ignored) {
      }
    }
Exemplo n.º 17
0
 /**
  * Changes the frame's location to a more central screen location
  *
  * @param frame the frame to be moved
  * @param X how far right to move the frame
  * @param Y how far down to move the frame
  */
 public static void changeFrameLocation(Component frame, int X, int Y) {
   Point location = frame.getLocation(); // the window's current location
   // move the window over and down a certain amount of pixels
   location.translate(X, Y);
   // set the location
   frame.setLocation(location);
 }
 /**
  * Updates the position and size of the edit panel relative to the given location.
  *
  * @param loc the location the edit panel should be relative to
  * @param absolute if {@code true} the loc is treated as absolute position on the process
  *     renderer; if {@code false} it is treated as relative to the current process
  */
 private void updateEditPanelPosition(final Rectangle2D loc, final boolean absolute) {
   int panelX = (int) loc.getCenterX() - EDIT_PANEL_WIDTH / 2;
   int panelY = (int) loc.getY() - EDIT_PANEL_HEIGHT - ProcessDrawer.PADDING;
   // if panel would be outside process renderer, fix it
   if (panelX < WorkflowAnnotation.MIN_X) {
     panelX = WorkflowAnnotation.MIN_X;
   }
   if (panelY < 0) {
     panelY = (int) loc.getMaxY() + ProcessDrawer.PADDING;
   }
   // last fallback is cramped to the bottom. If that does not fit either, don't care
   if (panelY + EDIT_PANEL_HEIGHT > view.getSize().getHeight() - ProcessDrawer.PADDING * 2) {
     panelY = (int) loc.getMaxY();
   }
   int index = view.getModel().getProcessIndex(model.getSelected().getProcess());
   if (absolute) {
     editPanel.setBounds(panelX, panelY, EDIT_PANEL_WIDTH, EDIT_PANEL_HEIGHT);
   } else {
     Point absoluteP =
         ProcessDrawUtils.convertToAbsoluteProcessPoint(
             new Point(panelX, panelY), index, rendererModel);
     editPanel.setBounds(
         (int) absoluteP.getX(), (int) absoluteP.getY(), EDIT_PANEL_WIDTH, EDIT_PANEL_HEIGHT);
   }
 }
Exemplo n.º 19
0
  public TabSpawnable spawn() {
    JFrame f = new JFrame();
    f.getContentPane().setLayout(new BorderLayout());
    f.setTitle(_title);
    TabSpawnable newPanel = (TabSpawnable) clone();
    if (newPanel == null) return null; // failed to clone
    newPanel.setTitle(_title);
    if (newPanel instanceof TabToDoTarget) {
      TabToDoTarget me = (TabToDoTarget) this;
      TabToDoTarget it = (TabToDoTarget) newPanel;
      it.setTarget(me.getTarget());
    } else if (newPanel instanceof TabModelTarget) {
      TabModelTarget me = (TabModelTarget) this;
      TabModelTarget it = (TabModelTarget) newPanel;
      it.setTarget(me.getTarget());
    }
    f.getContentPane().add(newPanel, BorderLayout.CENTER);
    Rectangle bounds = getBounds();
    bounds.height += OVERLAPP * 2;
    f.setBounds(bounds);

    Point loc = new Point(0, 0);
    SwingUtilities.convertPointToScreen(loc, this);
    loc.y -= OVERLAPP;
    f.setLocation(loc);
    f.setVisible(true);

    if (_tear && (getParent() instanceof JTabbedPane)) ((JTabbedPane) getParent()).remove(this);

    return newPanel;
  }
Exemplo n.º 20
0
  /** make new shape polygon */
  private void reMakePolygonShape() {
    ConvexHull convexHull;

    List<Point> newPoints = new ArrayList<Point>();

    for (int j = 0; j < polygon.npoints; j++) {

      if (mainClusterShape.contains(polygon.xpoints[j], polygon.ypoints[j])) {
        newPoints.add(new Point(polygon.xpoints[j], polygon.ypoints[j]));
      }
    }

    for (Point2D point2D : getIntersectPoint()) {
      newPoints.add(new Point((int) point2D.getX(), (int) point2D.getY()));
    }

    for (int i = 0; i < mainClusterShape.npoints; i++) {
      if (polygon.contains(mainClusterShape.xpoints[i], mainClusterShape.ypoints[i])) {
        Point point = new Point(mainClusterShape.xpoints[i], mainClusterShape.ypoints[i]);
        newPoints.add(point);
      }
    }

    convexHull = new ConvexHull();

    for (Point point : newPoints) {
      convexHull.addPoint((int) point.getX(), (int) point.getY());
    }

    setPolygon(convexHull.convex());
    newPoints.clear();
  }
Exemplo n.º 21
0
  /**
   * removeWordFromSlot()
   *
   * <p>Clears each position in the slot it's passed, but ONLY those positions containing letters
   * NOT used by any other words according to the letterUsage array. Also marks the word that used
   * to be in the slot as UNUSED.
   */
  private void removeWordFromSlot(CrosswordWord w, CrosswordSpace slot) {
    Point position = new Point(slot.getStart());

    for (int i = 0; i < slot.getLength(); i++) {

      // One fewer word is now using the letter at this position:

      letterUsage[position.x][position.y]--;

      // If no words are now using this letter, clear it:

      if (letterUsage[position.x][position.y] == 0) {
        puzzle[position.x][position.y] = BLANK;
      }

      // Advance to the next position in the slot:

      position.x += slot.getDirection().x;
      position.y += slot.getDirection().y;
    }

    // Mark the word as UNUSED -- ie., available to be placed
    // elsewhere in the puzzle:

    w.setUsed(false);
  }
Exemplo n.º 22
0
  /** Allows the user to edit all the parameters of an ABug by typing into the console */
  public void edit() {
    System.out.println("Name: ");
    try {
      name = bufferedReader.readLine();
    } catch (IOException e) {
      e.printStackTrace();
    }

    System.out.println("Energy: ");
    energy = InputHelper.readInteger(bufferedReader);

    System.out.println("Symbol: ");
    try {
      try {
        symbol = bufferedReader.readLine().charAt(0);
      } catch (IOException e) {
        e.printStackTrace();
      }
    } catch (IndexOutOfBoundsException ex) {
    }

    position = new Point();

    System.out.println("X Position: ");
    position.x = InputHelper.readInteger(bufferedReader);

    System.out.println("Y Position: ");
    position.y = InputHelper.readInteger(bufferedReader);

    System.out.println("Sensing Distance: ");
    maxSensingDistance = InputHelper.readInteger(bufferedReader);
  }
Exemplo n.º 23
0
 public void mergePastedImage() {
   if (pastedImage != null) {
     Graphics g = image.getGraphics();
     g.drawImage(pastedImage, (int) (start.getX() / scale), (int) (start.getY() / scale), this);
     repaint();
   }
 }
Exemplo n.º 24
0
  /*
   *  This method is called every time:
   *  - to make sure the viewport is returned to its default position
   *  - to remove the horizontal scrollbar when it is not wanted
   */
  private void checkHorizontalScrollBar(BasicComboPopup popup) {
    //  Reset the viewport to the left

    JViewport viewport = scrollPane.getViewport();
    Point p = viewport.getViewPosition();
    p.x = 0;
    viewport.setViewPosition(p);

    //  Remove the scrollbar so it is never painted

    if (!scrollBarRequired) {
      scrollPane.setHorizontalScrollBar(null);
      return;
    }

    //	Make sure a horizontal scrollbar exists in the scrollpane

    JScrollBar horizontal = scrollPane.getHorizontalScrollBar();

    if (horizontal == null) {
      horizontal = new JScrollBar(JScrollBar.HORIZONTAL);
      scrollPane.setHorizontalScrollBar(horizontal);
      scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    }

    //	Potentially increase height of scroll pane to display the scrollbar

    if (horizontalScrollBarWillBeVisible(popup, scrollPane)) {
      Dimension scrollPaneSize = scrollPane.getPreferredSize();
      scrollPaneSize.height += horizontal.getPreferredSize().height;
      scrollPane.setPreferredSize(scrollPaneSize);
      scrollPane.setMaximumSize(scrollPaneSize);
      scrollPane.revalidate();
    }
  }
Exemplo n.º 25
0
  public UserInfoDialog(Frame parent) {
    super(parent, "Input", true);
    setLayout(null);

    l.setFont(default_font);
    l.setSize(50, 30);
    l.setLocation(30, 50);

    name.setFont(default_font);
    name.setSize(150, 30);
    name.setLocation(90, 50);
    // name.selectAll();

    ok.setFont(default_font);
    ok.setSize(50, 30);
    ok.setLocation(30, 90);

    add(l);
    add(name);
    add(ok);
    ok.addActionListener(this);
    setSize(300, 150);

    Point my_loc = parent.getLocation();
    my_loc.x += 50;
    my_loc.y += 150;
    setLocation(my_loc);
    show();
  }
Exemplo n.º 26
0
  @Override
  public void mouseDragged(MouseEvent e) {
    Canvas c = context.getTabbedPaneController().getCurrentTabContent();
    SelectionModel selectionModel = c.getSelectionModel();
    if (!selectionModel.prepareForMove()) {
      moved = false;
      return;
    }
    Point thisCoord = e.getPoint();
    int dx = thisCoord.x - previousPosition.x;
    int dy = thisCoord.y - previousPosition.y;
    if (selectionRec == null) {
      selectionRec = selectionModel.getSelectionBounds();
    }
    selectionRec.setRect(
        selectionRec.getX() + dx,
        selectionRec.getY() + dy,
        selectionRec.getWidth(),
        selectionRec.getHeight());
    c.setSelectionRectangleBounds(
        selectionRec.getX(),
        selectionRec.getY(),
        selectionRec.getWidth(),
        selectionRec.getHeight());

    c.setShowSelectionRectangle(true);

    c.repaint();
    previousPosition = (Point) thisCoord.clone();
    moved = true;
  }
Exemplo n.º 27
0
  public void mouseReleased(java.awt.event.MouseEvent e) {
    if (e.isPopupTrigger()) {
      doPopup(e);
      return;
    }
    if (org.nlogo.awt.Mouse.hasButton1(e)) {
      java.awt.Point p = e.getPoint();
      java.awt.Rectangle rect = this.getBounds();

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

      selectionRect = null;
      glassPane.setVisible(false);

      if (newWidget != null) {
        newWidget.selected(true);
        newWidget.foreground();
        newWidget.isNew(true);
        new org.nlogo.window.Events.EditWidgetEvent(null).raise(this);
        newWidget.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
        newWidget.isNew(false);
        newWidget = null;
      }
    }
  }
Exemplo n.º 28
0
  /** Sets the location for predicted pentomino */
  public void predictDrop() {

    predictedLocation = (Point) pentominoLocation.clone();
    while (nextDropLegal(activePentomino, gameBoard.getBoard(), predictedLocation)) {
      predictedLocation.setLocation(predictedLocation.getX(), predictedLocation.getY() + 1);
    }
  }
 @Override
 protected RelativePoint getPointToShowResults() {
   Rectangle rect = myEntryTable.getCellRect(myEntryTable.getSelectedRow(), 1, false);
   Point location = rect.getLocation();
   location.y += rect.height;
   return new RelativePoint(myEntryTable, location);
 }
Exemplo n.º 30
0
 @FXML
 private void handleExportItemAction(ActionEvent event) {
   try {
     BufferedWriter bw =
         new BufferedWriter(
             new OutputStreamWriter(new FileOutputStream("imageInformation.csv"), "UTF-8"));
     for (ImageInformation img : imgMan.images) {
       StringBuffer oneLine = new StringBuffer();
       oneLine.append(img.getPath());
       oneLine.append(";");
       for (Point p : img.getPoints()) {
         oneLine.append(p.getX() + "," + p.getY());
       }
       oneLine.append(";");
       for (ImageInformation.Type t : img.getTypes()) {
         oneLine.append(t.toString());
       }
       oneLine.append(";");
       for (double d : img.getFrequency()) {
         oneLine.append(d + ",");
       }
       oneLine.append(";");
       bw.write(oneLine.toString());
       bw.newLine();
     }
     bw.flush();
     bw.close();
   } catch (UnsupportedEncodingException e) {
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
   }
 }