Package cranks.undo

Examples of cranks.undo.ConstructionStep


        JOptionPane.showMessageDialog(this, "Please enter numerical value for radius",
                                      "Try Again", JOptionPane.ERROR_MESSAGE);
        tfRadius.requestFocus(true);
        return;
      }
      ConstructionStep step = new ConstructionStep(this, new Object[]{centre,
                                                        radius}, CENTRE_RADIUS);
      doConstruction(step);
    }
    if (tabbedPane.getSelectedComponent() == pThreePoints) {
      Point point1 = (Point)cPoint1.getSelectedItem();
      Point point2 = (Point)cPoint2.getSelectedItem();
      Point point3 = (Point)cPoint3.getSelectedItem();
      ConstructionStep step = new ConstructionStep(this, new Object[]{point1,
                                point2, point3}, THREE_POINTS);
      doConstruction(step);
    }
  }
View Full Code Here


  private void modifyPoint() {
    try {
      double p_x = Double.parseDouble(tfNewCoordinatesX.getText());
      double p_y = Double.parseDouble(tfNewCoordinatesY.getText());
      Point oldPoint = (Point)cSelectPoint.getSelectedItem();
      ConstructionStep step = new ConstructionStep(this,
        new Object[]{new Double(oldPoint.getX()), new Double(oldPoint.getY()),
        oldPoint, new Double(p_x), new Double(p_y)}, MODIFY_POINT);
      doConstruction(step);
    } catch (NumberFormatException e) {
      JOptionPane.showMessageDialog(this, "Please enter numerical value",
View Full Code Here

            //check if num of clicks so far is equal to num of points
            //needed to draw object of type specified in mouseMode
            if (mouseClickCounter == mouseMode) {
              //create the object and add it to objects vector
              GeometricalObject objectToBeAdded = null;
              ConstructionStep step = null;
              switch (mouseMode) {
                case MOUSE_MODE_POINT:
                  objectToBeAdded = mouseClicks[0];
                  step = new ConstructionStep(this,
                              new Object[]{objectToBeAdded}, POINT);
                break;

                case MOUSE_MODE_LINE:
                  objectToBeAdded = new Line(mouseClicks[0], mouseClicks[1]);
                  step = new ConstructionStep(this,
                              new Object[]{objectToBeAdded}, LINE);
                break;

                case MOUSE_MODE_TRIANGLE:
                  objectToBeAdded = new Triangle(mouseClicks[0], mouseClicks[1],
                                                 mouseClicks[2]);
                  step = new ConstructionStep(this,
                              new Object[]{objectToBeAdded}, TRIANGLE);
                break;
                default :
              }
              doConstruction(step);
View Full Code Here

      System.err.println("Bad constructon type");
  }

  public void redesign(ConstructionStep step) {
    if (!step.needsModification()) {
      step = new ConstructionStep(step.getEditor(), step.getInputs(),
                                  step.getConstructionType());
      doConstruction(step);
    }
    if (step.getConstructionType() == POINT)
      changeMode(OPERATING_MODE_DRAWING, MOUSE_MODE_POINT);
View Full Code Here

  }

  private void intersectObjects() {
    GeometricalObject object1 = (GeometricalObject)cObject1.getSelectedItem();
    GeometricalObject object2 = (GeometricalObject)cObject2.getSelectedItem();
    ConstructionStep step;
    if ((object1 instanceof Line) && (object2 instanceof Line))
      step = new ConstructionStep(this, new Object[]{object1,
                                                    object2}, INTERSECT_ONE_POINT);
    else
      step = new ConstructionStep(this, new Object[]{object1,
                                                    object2}, INTERSECT_TWO_POINTS);
    doConstruction(step);
  }
View Full Code Here

      }
    }
  }

  private void createLine() {
    ConstructionStep step = null;
    if(tabbedPane.getSelectedComponent() == pOnePoint) {///1 point
      try {
        Object length, slopeDegrees;
        if (rbLengthValue.isSelected())
          length = new Double(Double.parseDouble(tfLength.getText()));
        else
          length = (GeometricalObject)cLengthReference.getSelectedItem();
        if (rbSlopeValue.isSelected())
          slopeDegrees = new Double(Double.parseDouble(tfSlope.getText()));
        else
          slopeDegrees = (GeometricalObject)cSlopeReference.getSelectedItem();
        Point p = (Point)cPoint.getSelectedItem();
        step = new ConstructionStep(this, new Object[]{p, length,
                            slopeDegrees}, ONE_POINT);
        doConstruction(step);
      } catch (NumberFormatException e) {
        JOptionPane.showMessageDialog(this, "Please enter numerical value",
                                    "Try Again", JOptionPane.ERROR_MESSAGE);
        return;
      }
    }
    if(tabbedPane.getSelectedComponent() == pTwoPoints) {///2 point
      Point p1 = (Point)cPoint1.getSelectedItem();
      Point p2 = (Point)cPoint2.getSelectedItem();
      step = new ConstructionStep(this, new Object[]{p1, p2}, TWO_POINTS);
      doConstruction(step);
    }
  }
View Full Code Here

  private void createTriangle() {
    if (tabbedPane.getSelectedComponent() == pThreePoints) {
      Point point1 = (Point)cPoint1.getSelectedItem();
      Point point2 = (Point)cPoint2.getSelectedItem();
      Point point3 = (Point)cPoint3.getSelectedItem();
      ConstructionStep step = new ConstructionStep(this, new Object[]{point1,
                          point2, point3}, THREE_POINTS);
      doConstruction(step);
    }
    if (tabbedPane.getSelectedComponent() == pPointLine) {
      Point vertexPoint = (Point)cPoint.getSelectedItem();
      Line edgeLine = (Line)cLine.getSelectedItem();
      ConstructionStep step = new ConstructionStep(this,
                          new Object[]{vertexPoint, edgeLine}, POINT_LINE);
      doConstruction(step);
    }
  }
View Full Code Here

      for (int i = 0; i<inputs.length; i++) {
        if (inputs[i] instanceof GeometricalObject)
          inputs[i] = objects.elementAt(
                      ((GeometricalObject)inputs[i]).getNumber() - 1);
      }
      step = new ConstructionStep(step.getEditor(), inputs,
                                  step.getConstructionType());
      doConstruction(step);
    }
  }
View Full Code Here

            if (selectedObj.elementAt(j).intValue() - 1 == i) {
              visibilityToggled[i] = Boolean.FALSE;
              break;
            }
        }
      ConstructionStep step = new ConstructionStep(this, visibilityToggled,
                                                    HIDE_OBJECT);
      doConstruction(step);
    }
    if (tabbedPane.getSelectedComponent() == pRemoveObject) {
      GeometricalObject ob = (GeometricalObject)cRemoveObject.getSelectedItem();
      ConstructionStep step = new ConstructionStep(this, new Object[]{ob},
                                                    REMOVE_OBJECT);
      doConstruction(step);
    }
  }
View Full Code Here

  private void addPoint() {
    try {
      double p_x = Double.parseDouble(tfNewPointX.getText());
      double p_y = Double.parseDouble(tfNewPointY.getText());
      ConstructionStep step = new ConstructionStep(this,
                new Object[]{new Double(p_x), new Double(p_y)}, ADD_POINT);
      doConstruction(step);
    } catch (NumberFormatException e) {
      JOptionPane.showMessageDialog(this, "Please enter numerical value",
                                  "Try Again", JOptionPane.ERROR_MESSAGE);
View Full Code Here

TOP

Related Classes of cranks.undo.ConstructionStep

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.