Exemplo n.º 1
0
  /**
   * Generate the grab points, checking the OMGraphic to see if it contains information about what
   * the grab points should look like.
   *
   * @param proj
   */
  protected void generateGrabPoints(Projection proj) {

    DrawingAttributes grabPointDA = null;
    Object obj = poly.getAttribute(EditableOMGraphic.GRAB_POINT_DRAWING_ATTRIBUTES_ATTRIBUTE);
    if (obj instanceof DrawingAttributes) {
      grabPointDA = (DrawingAttributes) obj;
    }

    int index = 0;
    // Generate all the grab points, but also check to make sure the drawing
    // attributes are right
    for (GrabPoint gb : polyGrabPoints) {
      if (gb != null) {

        if (selectNodeIndex == index) {
          Object daobj =
              poly.getAttribute(EditableOMGraphic.SELECTED_GRAB_POINT_DRAWING_ATTRIBUTES_ATTRIBUTE);
          if (daobj instanceof DrawingAttributes) {
            ((DrawingAttributes) daobj).setTo(gb);
          }
        } else if (grabPointDA != null) {
          grabPointDA.setTo(gb);
        } else {
          gb.setDefaultDrawingAttributes(GrabPoint.DEFAULT_RADIUS);
        }

        gb.generate(proj);
      }

      index++;
    }

    if (gpo != null) {

      if (grabPointDA != null) {
        grabPointDA.setTo(gpo);
      } else {
        gpo.setDefaultDrawingAttributes(GrabPoint.DEFAULT_RADIUS);
      }

      gpo.generate(proj);
      gpo.updateOffsets();
    }
  }
Exemplo n.º 2
0
  /**
   * Given a MouseEvent, check the source, and if it's a MapBean, then grab the projection and
   * java.awt.Graphics from it to use for generation and rendering of the EditableOMGraphic objects.
   *
   * @param e MouseEvent
   * @param firmPaint true if the graphic is being rendered at rest, with fill colors and true
   *     colors, with the grab point if the state allows it. If false, then the fill color will not
   *     be used, and just the graphic will be drawn. Use false for graphics that are moving.
   */
  public void redraw(MouseEvent e, boolean firmPaint, boolean drawXOR) {
    if (DEBUG) {
      Debug.output("EditableOMGraphic.redraw(" + (firmPaint ? "firmPaint)" : ")"));
    }

    if (e == null) {
      if (lastMouseEvent == null) {
        return;
      }
      e = lastMouseEvent;
    }

    Object obj = e.getSource();
    if (!(obj instanceof MapBean)) {
      return;
    }

    MapBean map = (MapBean) obj;
    Graphics g = map.getGraphics();

    OMGraphic graphic = getGraphic();

    if (firmPaint) {
      // So, with a firm paint, we want to clean the screen. If
      // the map is being buffered, we need to clean out the
      // buffer, which is why we set the Request paint to true,
      // to get the image rebuilt. Otherwise, a copy of the
      // graphic remains.
      map.setBufferDirty(true);
      graphic.generate(getProjection());
      map.repaint();
    } else {
      // If we get here, we are painting a moving object, so we
      // only want to do the outline to make it as fast as
      // possible.
      holder.setFrom(graphic);
      DrawingAttributes.DEFAULT.setTo(graphic);

      modifyOMGraphicForEditRender();
      graphic.regenerate(getProjection());

      if (drawXOR) {
        g.setXORMode(Color.lightGray);
        g.setColor((Color) graphic.getDisplayPaint());

        render(g);
      }

      GrabPoint gp = getMovingPoint();
      if (gp != null) {
        gp.set(e.getX(), e.getY());
        if (gp instanceof OffsetGrabPoint) {
          ((OffsetGrabPoint) gp).moveOffsets();
        }
        setGrabPoints();
      }
    }

    if (!firmPaint) {
      generate(getProjection());
      render(g);
      holder.setTo(graphic);
    }

    resetOMGraphicAfterEditRender();
    g.dispose();

    lastMouseEvent = e;
  }