Ejemplo n.º 1
0
  /** Clean the surface all the painting is taking place over. */
  public void cleanMap(MouseEvent e) {
    Object obj = e.getSource();
    if (!(obj instanceof MapBean)) {
      return;
    }

    // Could call repaint(), but I think we should paint in this
    // thread...
    MapBean map = (MapBean) obj;
    // Gets the buffer cleaned out.
    map.setBufferDirty(true);
    map.paintChildren(map.getGraphics());
  }
Ejemplo 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;
  }