Exemplo n.º 1
0
  public void scrollTo(GregorianCalendar date) {
    int left = painter.millisecondsToPixels(date.getTimeInMillis()) - 30;
    //		left = painter.toPixels( date.getTimeInMillis() );
    int top = 0;
    Rectangle r = new Rectangle(left, top, events.getWidth(), 10);
    log("ScrollTo: " + date.getTime() + " " + r.toString());
    //		scrollRectToVisible( r );

    events.scrollRectToVisible(r);
  }
Exemplo n.º 2
0
  public void paint(final Graphics graphic) {
    redrawCount++;
    graphic.translate(insets.left, insets.top);
    final Rectangle paintArea = graphic.getClipBounds();
    final Rectangle layoutArea = layoutViews();
    if (layoutArea != null) {
      paintArea.union(layoutArea);
    }

    if (spy != null) {
      spy.redraw(paintArea.toString(), redrawCount);
    }
    if (UI_LOG.isDebugEnabled()) {
      UI_LOG.debug(
          "------ repaint viewer #"
              + redrawCount
              + " "
              + paintArea.x
              + ","
              + paintArea.y
              + " "
              + paintArea.width
              + "x"
              + paintArea.height);
    }

    final Canvas c = createCanvas(graphic, paintArea);
    if (background != null) {
      background.draw(c.createSubcanvas(), rootView.getSize());
    }

    // paint views
    if (rootView != null) {
      rootView.draw(c.createSubcanvas());
    }
    // paint overlay

    final Bounds bounds = overlayView.getBounds();
    if (paintArea.intersects(
        new Rectangle(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()))) {
      overlayView.draw(c.createSubcanvas(bounds));
    }

    /*
     * for (int i = 0; i < panes.length; i++) {
     * panes[i].draw(c.createSubcanvas()); }
     */
    // paint status
    // paintUserStatus(bufferGraphics);
    // blat to screen
    if (doubleBuffering) {
      graphic.drawImage(doubleBuffer, 0, 0, null);
    }
    if (showRepaintArea) {
      graphic.setColor(
          ((AwtColor) Toolkit.getColor(ColorsAndFonts.COLOR_DEBUG_BOUNDS_REPAINT)).getAwtColor());
      graphic.drawRect(paintArea.x, paintArea.y, paintArea.width - 1, paintArea.height - 1);
      graphic.drawString("#" + redrawCount, paintArea.x + 3, paintArea.y + 15);
    }

    // paint status
    paintStatus(graphic);
  }
  /**
   * Evaluates the requested envelope and builds a new adjusted version of it fitting this coverage
   * envelope.
   *
   * <p>While adjusting the requested envelope this methods also compute the source region as a
   * rectangle which is suitable for a successive read operation with {@link ImageIO} to do
   * crop-on-read.
   *
   * @param requestedBBox is the envelope we are requested to load.
   * @param destinationRasterArea represents the area to load in raster space. This parameter cannot
   *     be null since it gets filled with whatever the crop region is depending on the <code>
   *     requestedEnvelope</code>.
   * @param requestedRasterArea is the requested region where to load data of the specified
   *     envelope.
   * @param readGridToWorld the Grid to world transformation to be used
   * @return the adjusted requested envelope, empty if no requestedEnvelope has been specified,
   *     {@code null} in case the requested envelope does not intersect the coverage envelope or in
   *     case the adjusted requested envelope is covered by a too small raster region (an empty
   *     region).
   * @throws DataSourceException
   * @throws DataSourceException in case something bad occurs
   */
  private void computeRequestSpatialElements() throws DataSourceException {

    //
    // Inspect the request and precompute transformation between CRS. We
    // also check if we can simply adjust the requested GG in case the
    // request CRS is different from the coverage native CRS but the
    // transformation is simply an affine transformation.
    //
    // In such a case we can simplify our work by adjusting the
    // requested grid to world, preconcatenating the coordinate
    // operation to change CRS
    //
    inspectCoordinateReferenceSystems();

    //
    // WE DO HAVE A REQUESTED AREA!
    //

    //
    // Create the crop bbox in the coverage CRS for cropping it later on.
    //
    computeCropBBOX();
    if (empty || (cropBBox != null && cropBBox.isEmpty())) {
      if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "RequestedBBox empty or null");
      }
      // this means that we do not have anything to load at all!
      empty = true;
      return;
    }

    //
    // CROP SOURCE REGION using the refined requested envelope
    //
    computeCropRasterArea();
    if (empty || (destinationRasterArea != null && destinationRasterArea.isEmpty())) {
      if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "CropRasterArea empty or null");
      }
      // this means that we do not have anything to load at all!
      return;
    }

    if (LOGGER.isLoggable(Level.FINER)) {
      StringBuilder sb =
          new StringBuilder("Adjusted Requested Envelope = ")
              .append(requestedBBox.toString())
              .append("\n")
              .append("Requested raster dimension = ")
              .append(requestedRasterArea.toString())
              .append("\n")
              .append("Corresponding raster source region = ")
              .append(requestedRasterArea.toString());
      LOGGER.log(Level.FINER, sb.toString());
    }

    //
    // Compute the request resolution from the request
    //
    computeRequestedResolution();
  }