Package org.nlogo.shape

Examples of org.nlogo.shape.Element


  public void paintComponent(java.awt.Graphics g) {
    super.paintComponent(g);
    org.nlogo.api.Graphics2DWrapper g2 = new org.nlogo.api.Graphics2DWrapper((java.awt.Graphics2D) g);
    java.awt.Rectangle bounds = getBounds();
    List<Element> elements = shape.getElements();
    Element element;

    // If the shape is rotatable, draw a gray background with a
    // black circle in the middle to show the user where to draw
    if (editorDialog.isRotatable()) {
      g.setColor(java.awt.Color.DARK_GRAY.darker());
      g.fillRect(0, 0, bounds.width, bounds.height);
      g.setColor(java.awt.Color.BLACK);
      g.fillOval(0, 0, bounds.width, bounds.height);
    }

    gridGapX = (double) bounds.width / VectorShape.NUM_GRID_LINES;
    gridGapY = (double) bounds.height / VectorShape.NUM_GRID_LINES;
    g.setColor(java.awt.Color.DARK_GRAY.darker());

    for (int i = 1; i < VectorShape.NUM_GRID_LINES; ++i) {
      g.drawLine(i * Element.round(gridGapX), 0,
          i * Element.round(gridGapX), bounds.height);
      g.drawLine(0, i * Element.round(gridGapY),
          bounds.width, i * Element.round(gridGapY));
    }

    // Draw crosshairs on top of the grid
    g.setColor(java.awt.Color.DARK_GRAY);
    g.drawLine(bounds.width / 2, 0, bounds.width / 2, bounds.height);
    g.drawLine(0, bounds.height / 2, bounds.width, bounds.width / 2);
    g.drawLine(0,
        VectorShape.NUM_GRID_LINES * Element.round(gridGapY),
        bounds.width,
        VectorShape.NUM_GRID_LINES * Element.round(gridGapY));

    // Draw the elements
    g2.antiAliasing(true);

    for (int i = 0; i < elements.size(); ++i) {
      element = elements.get(i);
      g.setColor(element.getColor());
      element.draw(g2, null,
          IS_MAC ? 299 : 300,
          0);
    }

    if (tempElement != null) {
View Full Code Here


  }

  // Find which element the user pressed the mouse button inside
  private void checkElements(java.awt.Point start) {

    Element currentElement;

    // the elements are stored in back-to-front order, but we want
    // to favor front elements over back elements here, so we
    // scan the list backwards - SAB/ST 6/11/04
    for (int i = (shape.getElements().size() - 1); i >= 0; i--) {
      currentElement = shape.getElements().get(i);

      if (hasSelectedElement()) {
        int spIndex = checkHandles(start);
        if (spIndex != -1) {
          selectHandle(spIndex, selectedElement);
          return;
        }
      }

      if (currentElement.contains(start)) {
        draggingElement = true;
        if (hasSelectedElement()) {
          selectedElement.deselect();
        }
        currentElement.select();
        selectedElement = currentElement;
        editorDialog.makeUndoableModification
            (selectedElement,
                shape.getElements().indexOf(selectedElement));
        shape.changed();
View Full Code Here

    duplicateSelected.setEnabled(false);
    duplicateSelected.addActionListener
        (new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            if (shapeView.getSelectedElement() != null) {
              Element newElement =
                  (Element) shapeView.getSelectedElement().clone();
              shape.add(newElement);
              makeUndoableDraw(newElement);
            }
          }
View Full Code Here

TOP

Related Classes of org.nlogo.shape.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.