Examples of GeometricalObject


Examples of cranks.geom.GeometricalObject

    doConstruction(step);
  }

  public void doConstruction(ConstructionStep step) {
    if (step.getConstructionType() == INTERSECT_ONE_POINT) {
      GeometricalObject object1 = (GeometricalObject)step.getInputs()[0];
      GeometricalObject object2 = (GeometricalObject)step.getInputs()[1];
      Point[] intersectionPoints = new Point[2];
      if ((object1.canIntersect(object2)) && (object1.getType() != Point.TYPE)) {
        intersectionPoints = (Point[])object1.intersect(object2);
        intersectionPoints[0].addToObjects(objects);
        clearAndHide();
        step.setOutputs(intersectionPoints);
        fireUndoableEditUpdate(new UndoableEditEvent(this, step));
      }
      else {
        JOptionPane.showMessageDialog(this, "Objects cannot intersect",
                                "Try Again", JOptionPane.ERROR_MESSAGE);
        initDialog();
      }
    }
    else if (step.getConstructionType() == INTERSECT_TWO_POINTS) {
      GeometricalObject object1 = (GeometricalObject)step.getInputs()[0];
      GeometricalObject object2 = (GeometricalObject)step.getInputs()[1];
      Point[] intersectionPoints = new Point[2];
      if ((object1.canIntersect(object2)) && (object1.getType() != Point.TYPE)) {
        intersectionPoints = (Point[])object1.intersect(object2);
        intersectionPoints[0].addToObjects(objects);
        intersectionPoints[1].addToObjects(objects);
View Full Code Here

Examples of cranks.geom.GeometricalObject

  private void showObjects() {
    cObject1.removeAllItems();
    cObject2.removeAllItems();
    //display all lines and circles.
    for(int t=(objects.size()-1);t>=0;t--) {
      GeometricalObject ob = objects.elementAt(t);
      if ((ob.getType() == Line.TYPE) || (ob.getType() == Circle.TYPE)) {
        cObject1.addItem(ob);
        cObject2.addItem(ob);
      }
    }
  }
View Full Code Here

Examples of cranks.geom.GeometricalObject

    cPoint3.removeAllItems();
    cPoint.removeAllItems();
    cLine.removeAllItems();

    for (int i = objects.size()-1; i>=0; i--) {
      GeometricalObject o = (GeometricalObject)(objects.elementAt(i));
      if (o.getType() == Point.TYPE) {
        cPoint1.addItem(o);
        cPoint2.addItem(o);
        cPoint3.addItem(o);
        cPoint.addItem(o);
      }
      if (o.getType() == Line.TYPE) {
        cLine.addItem(o);
      }
    }
  }
View Full Code Here

Examples of cranks.geom.GeometricalObject

        JOptionPane.showMessageDialog(this, "Please enter numerical value",
                                      "Try Again", JOptionPane.ERROR_MESSAGE);
        return;
      }
    }
    GeometricalObject o = (GeometricalObject)cSelectObject.getSelectedItem();
    ConstructionStep step = new ConstructionStep(this, new Object[] {o,
              new Double(translationX), new Double(translationY),
              new Double(rotation), fixedPoint}, MOVE);
    doConstruction(step);
  }
View Full Code Here

Examples of cranks.geom.GeometricalObject

    doConstruction(step);
  }

  public void doConstruction(ConstructionStep step) {
    if (step.getConstructionType() == MOVE) {
      GeometricalObject o = (GeometricalObject)step.getInputs()[0];
      Point translation = new Point(((Double)step.getInputs()[1]).doubleValue(),
                                    ((Double)step.getInputs()[2]).doubleValue());
      Angle rotation = new Angle(((Double)step.getInputs()[3]).doubleValue());
      Point fixedPoint = (Point)step.getInputs()[4];
      if (fixedPoint.getAssocObjects().contains(o)) {
        fixedPoint = new Point(fixedPoint.getX(), fixedPoint.getY());
        fixedPoint.move(translation, new Angle(0), new Point());
        step.getInputs()[4] = fixedPoint;
      }
      o.move(translation, rotation, fixedPoint);
      clearAndHide();
      step.setOutputs(new Object[]{o});
      fireUndoableEditUpdate(new UndoableEditEvent(this, step));
    }
    else
View Full Code Here

Examples of cranks.geom.GeometricalObject

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

  public void undoConstruction(ConstructionStep step) {
    if (step.getConstructionType() == MOVE) {
      GeometricalObject o = (GeometricalObject)step.getInputs()[0];
      Point translation = new Point(((Double)step.getInputs()[1]).doubleValue(),
                                    ((Double)step.getInputs()[2]).doubleValue());
      Angle rotation = new Angle(((Double)step.getInputs()[3]).doubleValue());
      Point fixedPoint = (Point)step.getInputs()[4];
      rotation = rotation.mul(-1);
      translation = new Point(translation.getX()*(-1), translation.getY()*(-1));
      o.move(new Point(), rotation, fixedPoint);
      o.move(translation, new Angle(0), fixedPoint);
    }
    else
      System.err.println("Bad construction type");
  }
View Full Code Here

Examples of cranks.geom.GeometricalObject

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

  public void redoConstruction(ConstructionStep step) {
    if (step.getConstructionType() == MOVE) {
      GeometricalObject o = (GeometricalObject)step.getInputs()[0];
      Point translation = new Point(((Double)step.getInputs()[1]).doubleValue(),
                                    ((Double)step.getInputs()[2]).doubleValue());
      Angle rotation = new Angle(((Double)step.getInputs()[3]).doubleValue());
      Point fixedPoint = (Point)step.getInputs()[4];
      o.move(translation, rotation, fixedPoint);
    }
    else
      System.err.println("Bad construction type");
  }
View Full Code Here

Examples of cranks.geom.GeometricalObject

  private void showObjects() {
    cSelectObject.removeAllItems();
    cSelectLine.removeAllItems();
    cSelectPoint.removeAllItems();
    for (int i = objects.size()-1; i >= 0; i--) {
      GeometricalObject o = (GeometricalObject)(objects.elementAt(i));
      cSelectObject.addItem(o);
      if (o.getType() == Line.TYPE)
        cSelectLine.addItem(o);
      if (o.getType() == Point.TYPE)
        cSelectPoint.addItem(o);
    }
  }
View Full Code Here

Examples of cranks.geom.GeometricalObject

    cPickSide.removeAllItems();
    cNewSide.removeAllItems();
    cSelectOrientation.removeAllItems();
    lOrientation.setText("");
    for (int i = (objects.size() - 1); i>=0; i--) {
      GeometricalObject o = objects.elementAt(i);
      if (o.getType() == Line.TYPE)
        cNewSide.addItem(o);
      if (o.getType() == Triangle.TYPE)
        cTriangle.addItem(o);
    }
  }
View Full Code Here

Examples of cranks.geom.GeometricalObject

    cLink2.removeAllItems();
    cLink3.removeAllItems();
    cLink4.removeAllItems();
    cTernaryLink.removeAllItems();
    for (int i = objects.size() - 1; i >= 0; i--) {
      GeometricalObject o = objects.elementAt(i);
      if (o instanceof Line) {
        cLink1.addItem(o);
        cLink2.addItem(o);
        cLink3.addItem(o);
        cLink4.addItem(o);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.