Package es.iiia.shapegrammar.shape

Examples of es.iiia.shapegrammar.shape.LineModel


        getPoints().get(0).getY());
    for (int i=1; i<getPoints().size(); i++) {
      path.lineTo(getPoints().get(i).getX(), getPoints().get(i).getY());
    }
   
    LineModel lineModel = (LineModel) model;
    if (lineModel.isClosed()) {
      path.lineTo(lineModel.getP1().getX(), lineModel.getP1().getY());
    }   
  } 
View Full Code Here


  @Override
  public boolean init(MouseEvent e) {   
    Point2D pt = editor.locatePoint(e.getPoint());
   
    if (model == null) {
      model = new LineModel()
      model.addPoint((Point2D) pt.clone());
      ctr = new PolyLineController(model)
      editor.getEditControllers().add(ctr);
      index = 0;
     
View Full Code Here

  }

  @Override
  public boolean init(MouseEvent e) {   
    Point2D pt = view.locatePoint(e.getPoint());
    model = new LineModel(pt, pt);   
    ctr = new LineController(model);
   
    view.getEditControllers().add(ctr);
   
    return true;
View Full Code Here

//    private static ArrayList<String> pairs;
//    private static Random random = new Random();
   
       public static void createMaximalLines(ArrayList<LineModel> currentLines) throws Exception {
        LineModel leftLine = null;
      LineModel rightLine = null;
        int rightIndex;

        for (int i = 0; i < currentLines.size(); i++) {
            for (int j = 0; j < currentLines.size(); j++) {
                // avoid duplicate testing
                if (i >= j) continue;

                // sort lines left to right
        rightIndex = (
            MathUtils.compare(currentLines.get(i).getP1(),
            currentLines.get(j).getP1()) == 1) ? i : j;
        leftLine = currentLines.get(rightIndex == i ? j : i);
        rightLine = currentLines.get(rightIndex);
               
                // proceed to test the lines
                if (MathUtils.compare(leftLine.getP2(), rightLine.getP1()) != -1 &&
                        MathUtils.vectorsEqual(leftLine, rightLine) &&
                        MathUtils.vectorsEqual(
                                leftLine.getP1(), leftLine.getP2(),
                                leftLine.getP1(), rightLine.getP2()
                        )) {

                  // set the line to the longest possible
                  if (MathUtils.compare(leftLine.getP2(), rightLine.getP2()) == -1) {
                    flipPoints(leftLine.getP2(), rightLine.getP2());
                  }
                 
                    Debugger.getInstance().addMessage("REMOVING: " + currentLines.get(rightIndex).toString());
                    currentLines.remove(rightIndex);
                    //decrease iterator
View Full Code Here

    // return state from the state bag
    return this.stateBag.getAvailableStates();
  }

  private void extractShape(ShapeModel originalShape, ShapeModel shape) {
    LineModel line, parent;

    for (NodeModel geom : originalShape.getChildrenArray()) {
      line = (LineModel) geom;

      // line holds pointer to maximal line
      parent = (LineModel) line.getParent();

      // remove parent line

      shape.getChildrenArray().remove(
          shape.getChildrenArray().indexOf(parent));
      shape.getChildrenArray().remove(parent);

      shape.reset();
      // add splitted line to parts

      // add left line

      // non vertical lines
      if (parent.getP1().getX() != parent.getP2().getX()) {
        if (parent.getP1().getX() < line.getP1().getX()) {
          shape.getChildrenArray().add(
              new LineModel(parent.getP1(), line.getP1()));
        }
        // add right line
        if (line.getP2().getX() < parent.getP2().getX()) {
          shape.getChildrenArray().add(
              new LineModel(line.getP2(), parent.getP2()));
        }
      } else {
        // vertical lines
        if (parent.getP1().getY() < line.getP1().getY()) {
          shape.getChildrenArray().add(
              new LineModel(parent.getP1(), line.getP1()));
        }
        // add right line
        if (line.getP2().getY() < parent.getP2().getY()) {
          shape.getChildrenArray().add(
              new LineModel(line.getP2(), parent.getP2()));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of es.iiia.shapegrammar.shape.LineModel

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.