Пример #1
0
  public void nodeDown(int x, int y) {
    log.info("nodeDn x=" + x + ", y=" + y);
    if (dtoLinks == null) {
      log.info("dtoLinks==null");
      dtoLinks = new DTOLinks();
      SCL.getCurrSecCanvas().getDtoCanvas().setDtoLinks(dtoLinks);
    }
    dtoLink = null;
    moving = false;

    Iterator<DTOLink> it = dtoLinks.getDTOLinks().iterator();
    while (it.hasNext()) {
      DTOLink p = it.next();
      if ((Math.abs(x - getCoord(p.getX())) ^ 2) + (Math.abs(y - getCoord(p.getY())) ^ 2)
          < (nodeRadius ^ 2)) {
        dtoLink = p;
        return;
      }
    }

    clear();

    DTOLink p = new DTOLink();
    p.setCanvasMapId(SCL.getCurrSecCanvas().getDtoCanvas().getId());
    p.setX(getRevCoord(x));
    p.setY(getRevCoord(y));

    dtoLinks.getDTOLinks().add(p);

    SCL.getCanvasDialog().updateCurrLinkNodes();

    draw(false);
  }
Пример #2
0
  public void draw(boolean highlight) {
    if (dtoLinks != null && dtoLinks.getDTOLinks().size() > 0) {
      CanvasScreen canvasScreen = SCL.getCurrPrimeCanvas().getCanvasScreen();
      Iterator<DTOLink> it;
      if (SCL.getCanvasDialog().isEdit()) {
        it = dtoLinks.getDTOLinks().iterator();
        while (it.hasNext()) {
          DTOLink p = it.next();
          canvasScreen.context1.setFillStyle(SCL.getCurrPrimeCanvas().getEditLineColor());
          canvasScreen.context1.beginPath();
          canvasScreen.context1.arc(
              getCoord(p.getX()), getCoord(p.getY()), nodeRadius, 0, Math.PI * 2.0, true);
          canvasScreen.context1.closePath();
          canvasScreen.context1.fill();
        }
      }

      //		log.severe("Resetting Polygon!");
      polygon = new Polygon();

      if (SCL.getCanvasDialog().isEdit()) {
        canvasScreen.context1.setLineWidth(2);
        canvasScreen.context1.setStrokeStyle(SCL.getCurrPrimeCanvas().getEditLineColor());

      } else {
        canvasScreen.context1.setLineWidth(1);
        canvasScreen.context1.setStrokeStyle(SCL.getCurrPrimeCanvas().getUserLineColor());
      }
      canvasScreen.context1.beginPath();
      it = dtoLinks.getDTOLinks().iterator();
      DTOLink p = it.next();
      canvasScreen.context1.moveTo(getCoord(p.getX()), getCoord(p.getY()));
      polygon.addPoint(getCoord(p.getX()), getCoord(p.getY()));
      while (it.hasNext()) {
        p = it.next();

        canvasScreen.context1.lineTo(getCoord(p.getX()), getCoord(p.getY()));

        polygon.addPoint(getCoord(p.getX()), getCoord(p.getY()));
      }
      canvasScreen.context1.closePath();

      if (highlight) {
        canvasScreen.context1.setGlobalAlpha(0.3);
        canvasScreen.context1.setFillStyle(SCL.getCurrPrimeCanvas().getUserShadeColor());
        canvasScreen.context1.fill();
      }

      canvasScreen.context1.setGlobalAlpha(1);
      canvasScreen.context1.stroke();
    }
  }
Пример #3
0
  public void nodeUp(int x, int y) {
    log.info("nodeUp!");
    if (dtoLink == null) {
      log.severe("nodeDn == null");
    }
    if (moving) {
      //			log.severe("moving!");
    }
    if (dtoLink != null && !moving) {
      //			log.info("x,y = " + x + ", " + y);
      //			log.info("x = " + x);
      //			log.info("dtoLink.x = " + getCoord(dtoLink.getX()));
      //			log.info("y = " + getRevCoord(y));
      //			log.info("dtoLink.y = " + getCoord(dtoLink.getY()));
      //			log.info("nodeUp 2! value = " + (Math.pow(x-getCoord(dtoLink.getX()),2) +
      // Math.pow(y-getCoord(dtoLink.getY()),2)) + ", nodeRadius = " + nodeRadius + " nodeRadius^2 =
      // " + (Math.pow(nodeRadius,2)));
      if (Math.pow(x - getCoord(dtoLink.getX()), 2) + Math.pow(y - getCoord(dtoLink.getY()), 2)
          <= Math.pow(nodeRadius, 2)) {
        //				log.info("nodeUp 2-a!");
        clear();
        dtoLinks.getDTOLinks().remove(dtoLink);
        draw(false);
      }
    }

    SCL.getCanvasDialog().updateCurrLinkNodes();
  }
Пример #4
0
  public void clear() {
    if (dtoLinks != null && dtoLinks.getDTOLinks().size() > 0) {
      CanvasScreen canvasScreen = SCL.getCurrPrimeCanvas().getCanvasScreen();

      String prevGlobalCompositeOperation = canvasScreen.context1.getGlobalCompositeOperation();
      canvasScreen.context1.setGlobalCompositeOperation("destination-out");

      Iterator<DTOLink> it = dtoLinks.getDTOLinks().iterator();
      while (it.hasNext()) {
        DTOLink p = it.next();
        canvasScreen.context1.setFillStyle("rgba(255,255,255,1.0)");
        canvasScreen.context1.beginPath();
        canvasScreen.context1.arc(
            getCoord(p.getX()), getCoord(p.getY()), nodeRadius + 1, 0, Math.PI * 2.0, true);
        canvasScreen.context1.closePath();
        canvasScreen.context1.fill();
      }

      canvasScreen.context1.setLineWidth(5);
      canvasScreen.context1.setStrokeStyle("rgba(255,255,255,1.0)");
      canvasScreen.context1.beginPath();
      it = dtoLinks.getDTOLinks().iterator();
      DTOLink p = it.next();
      canvasScreen.context1.moveTo(getCoord(p.getX()), getCoord(p.getY()));
      while (it.hasNext()) {
        p = it.next();

        canvasScreen.context1.lineTo(getCoord(p.getX()), getCoord(p.getY()));
      }
      canvasScreen.context1.closePath();
      canvasScreen.context1.setFillStyle("rgba(255,255,255,1.0)");
      canvasScreen.context1.setGlobalAlpha(1);
      canvasScreen.context1.fill();
      canvasScreen.context1.stroke();

      canvasScreen.context1.setGlobalCompositeOperation(prevGlobalCompositeOperation);
    }
  }