Exemplo n.º 1
0
  public void setLocation(GeneralPath gp) {
    if (gp != null) {
      Rectangle rect = gp.getBounds();

      double x = rect.getX();
      double y = rect.getY();

      if (anchor == ANCHOR_TOP || anchor == ANCHOR_CENTER || anchor == ANCHOR_BOTTOM) {
        x += rect.getWidth() / 2;
      } else if (anchor == ANCHOR_TOPRIGHT
          || anchor == ANCHOR_RIGHT
          || anchor == ANCHOR_BOTTOMRIGHT) {
        x += rect.getWidth();
      }

      if (anchor == ANCHOR_LEFT || anchor == ANCHOR_CENTER || anchor == ANCHOR_RIGHT) {
        y += rect.getHeight() / 2;
      } else if (anchor == ANCHOR_BOTTOMLEFT
          || anchor == ANCHOR_BOTTOM
          || anchor == ANCHOR_BOTTOMRIGHT) {
        y += rect.getHeight();
      }

      setLocation(new Point((int) x, (int) y));
    }
  }
Exemplo n.º 2
0
  /**
   * Compute the screen location of the controls overall rectangle bottom right corner according to
   * either the location center if not null, or the screen position.
   *
   * @param viewport the current viewport rectangle.
   * @param controls the overall controls rectangle
   * @return the screen location of the bottom left corner - south west corner.
   */
  protected Point computeLocation(Rectangle viewport, Rectangle controls) {
    double x;
    double y;

    if (this.locationCenter != null) {
      x = this.locationCenter.x - controls.width / 2;
      y = this.locationCenter.y - controls.height / 2;
    } else if (this.position.equals(AVKey.NORTHEAST)) {
      x = viewport.getWidth() - controls.width - this.borderWidth;
      y = viewport.getHeight() - controls.height - this.borderWidth;
    } else if (this.position.equals(AVKey.SOUTHEAST)) {
      x = viewport.getWidth() - controls.width - this.borderWidth;
      y = 0d + this.borderWidth;
    } else if (this.position.equals(AVKey.NORTHWEST)) {
      x = 0d + this.borderWidth;
      y = viewport.getHeight() - controls.height - this.borderWidth;
    } else if (this.position.equals(AVKey.SOUTHWEST)) {
      x = 0d + this.borderWidth;
      y = 0d + this.borderWidth;
    } else // use North East as default
    {
      x = viewport.getWidth() - controls.width - this.borderWidth;
      y = viewport.getHeight() - controls.height - this.borderWidth;
    }

    if (this.locationOffset != null) {
      x += this.locationOffset.x;
      y += this.locationOffset.y;
    }

    return new Point((int) x, (int) y);
  }
Exemplo n.º 3
0
  public boolean wallCollision(Bullet bullet) {
    Rectangle boundingBox = bullet.getBoundingBox();
    int tile;
    int tileWidth = tileMap.getTileWidth();
    int tileHeight = tileMap.getTileHeight();

    /*
     * nested four loop only is grabbing the 4 corners of the
     * bullet's hit box and checking the type of tiles that they
     * contact. The current bullets range from 8x8 to 17x17, so they
     * all can contact the same range of tiles at any given time:
     * 1-4 A bullet expires on contact with a solid object(besides
     * ring bullets)
     */

    for (int y = bullet.yPos;
        y <= bullet.yPos + boundingBox.getHeight();
        y += boundingBox.getHeight()) {
      for (int x = bullet.xPos;
          x <= bullet.xPos + boundingBox.getWidth();
          x += boundingBox.getWidth()) {
        int tileCoordX = (int) (x + distanceScrolled) / tileWidth;
        int tileCoordY = y / tileHeight;

        tile = tileMap.getTile(((tileCoordY) * tileMap.getTileMapWidth()) + (tileCoordX));
        if (tile < 17 || 23 < tile) {
          return true;
        }
      }
    }
    return false;
  }
 public void paintSelection(Graphics g, int rowMin, int rowMax, int colMin, int colMax) {
   for (int row = rowMin; row <= rowMax; row++) {
     for (int column = colMin; column <= colMax; column++) {
       if (!grid.isCellSpan(row, column)) {
         Rectangle cellBounds = grid.getCellBounds(row, column);
         if (grid.getSelectionModel().isSelected(row, column)) {
           g.setColor(Color.RED);
           g.drawRect(
               (int) cellBounds.getX() + 1,
               (int) cellBounds.getY() + 1,
               (int) cellBounds.getWidth() - 2,
               (int) cellBounds.getHeight() - 2);
         }
       } else {
         CellSpan span = grid.getSpanModel().getSpanOver(row, column);
         if (grid.getSelectionModel().isSelected(span.getRow(), span.getColumn())) {
           g.setColor(Color.RED);
           Rectangle cellBounds = grid.getCellBounds(span.getFirstRow(), span.getLastColumn());
           g.drawRect(
               (int) cellBounds.getX() + 1,
               (int) cellBounds.getY() + 1,
               (int) cellBounds.getWidth() - 2,
               (int) cellBounds.getHeight() - 2);
         }
       }
     }
   }
 }
Exemplo n.º 5
0
  public void paintTransition(Graphics2D g2, int state, Rectangle size, Image prev) {

    int length = getAnimationLength();
    int half = length / 2;
    double scale = size.getHeight() / length;
    int offset = 0;
    // calculate the fade out part
    if (state >= 0 && state < half) {
      // draw the saved version of the old tab component
      if (prev != null) {
        g2.drawImage(prev, (int) size.getX(), (int) size.getY(), null);
      }
      offset = (int) ((10 - state) * scale);
    }
    // calculate the fade in part
    if (state >= half && state < length) {
      g2.setColor(Color.white);
      offset = (int) ((state - 10) * scale);
    }

    // do the drawing
    g2.setColor(Color.white);
    Rectangle area =
        new Rectangle(
            (int) (size.getX() + offset),
            (int) (size.getY() + offset),
            (int) (size.getWidth() - offset * 2),
            (int) (size.getHeight() - offset * 2));

    g2.fill(area);
  }
Exemplo n.º 6
0
 /* (non-Javadoc)
  * @see at.fhhgb.mc.Shapes.GraphicPrimitive#draw(java.awt.Graphics)
  */
 @Override
 public void draw(Graphics g) {
   g.setColor(new Color(0, 0, 255));
   g.drawLine(x, y, x2, y2);
   if (getHovered()) {
     java.awt.Rectangle bounds = getBoundingBox();
     g.setColor(new Color(10, 10, 10));
     g.drawRect(
         (int) bounds.getX(),
         (int) bounds.getY(),
         (int) bounds.getWidth(),
         (int) bounds.getHeight());
   }
   if (getSelected()) {
     java.awt.Rectangle bounds = getBoundingBox();
     g.setColor(new Color(255, 0, 0));
     Graphics2D g2 = (Graphics2D) g;
     g2.setStroke(new BasicStroke(3));
     g2.drawRect(
         (int) bounds.getX(),
         (int) bounds.getY(),
         (int) bounds.getWidth(),
         (int) bounds.getHeight());
   }
 }
Exemplo n.º 7
0
  private Vec4 computeLocation(java.awt.Rectangle viewport, double scale) {
    double scaledWidth = scale * this.size.width;
    double scaledHeight = scale * this.size.height;

    double x;
    double y;

    if (this.locationCenter != null) {
      x = this.locationCenter.x - scaledWidth / 2;
      y = this.locationCenter.y - scaledHeight / 2;
    } else if (this.position.equals(AVKey.NORTHEAST)) {
      x = viewport.getWidth() - scaledWidth - this.borderWidth;
      y = viewport.getHeight() - scaledHeight - this.borderWidth;
    } else if (this.position.equals(AVKey.SOUTHEAST)) {
      x = viewport.getWidth() - scaledWidth - this.borderWidth;
      y = 0d + this.borderWidth;
    } else if (this.position.equals(AVKey.NORTHWEST)) {
      x = 0d + this.borderWidth;
      y = viewport.getHeight() - scaledHeight - this.borderWidth;
    } else if (this.position.equals(AVKey.SOUTHWEST)) {
      x = 0d + this.borderWidth;
      y = 0d + this.borderWidth;
    } else // use North East
    {
      x = viewport.getWidth() - scaledWidth / 2 - this.borderWidth;
      y = viewport.getHeight() - scaledHeight / 2 - this.borderWidth;
    }

    if (this.locationOffset != null) {
      x += this.locationOffset.x;
      y += this.locationOffset.y;
    }

    return new Vec4(x, y, 0);
  }
 public static com.parkingfinder.web.model.Rectangle convert(java.awt.Rectangle rect) {
   com.parkingfinder.web.model.Rectangle result = new com.parkingfinder.web.model.Rectangle();
   result.setMaxLeft(new Point(rect.getX(), rect.getY()));
   result.setMaxRight(new Point(rect.getX() + rect.getWidth(), rect.getY()));
   result.setMinRight(new Point(rect.getX() + rect.getWidth(), rect.getY() + rect.getHeight()));
   result.setMinLeft(new Point(rect.getX(), rect.getY() + rect.getHeight()));
   return result;
 }
Exemplo n.º 9
0
 public void setVisible(boolean flag) {
   Rectangle rc = m_mainframe.getBounds();
   Rectangle rcthis = getBounds();
   setBounds(
       (int) (rc.getWidth() - rcthis.getWidth()) / 2 + rc.x,
       (int) (rc.getHeight() - rcthis.getHeight()) / 2 + rc.y,
       (int) rcthis.getWidth(),
       (int) rcthis.getHeight());
   super.setVisible(flag);
 }
  @Override
  public void dropPerformed(CWidgetDropEvent event) {

    CandlestickWidget widget = event.getWidget();
    Point loc = widget.getWidget().getLocation();
    Rectangle sbounds = scene.getScene().getBounds();
    Rectangle wbounds = widget.getWidget().getBounds();

    double len = (sbounds.getHeight() - loc.y - wbounds.getHeight()) * point2pixel;
    FIHelper.add(widget.getCandlestick().instrument(), len);
  }
 private static Rectangle fitToScreen(
     @NotNull Dimension newDim, @NotNull RelativePoint popupPosition, JTable table) {
   Rectangle rectangle = new Rectangle(popupPosition.getScreenPoint(), newDim);
   ScreenUtil.fitToScreen(rectangle);
   if (rectangle.getHeight() != newDim.getHeight()) {
     int newHeight = (int) rectangle.getHeight();
     int roundedHeight = newHeight - newHeight % table.getRowHeight();
     rectangle.setSize((int) rectangle.getWidth(), Math.max(roundedHeight, table.getRowHeight()));
   }
   return rectangle;
 }
Exemplo n.º 12
0
  /**
   * TODO summary sentence for worldToScreenTransform ...
   *
   * @param bounds
   * @param rectangle
   * @return
   */
  public static AffineTransform worldToScreenTransform(
      BoundingBox mapExtent, Rectangle screenSize) {
    double scaleX = screenSize.getWidth() / mapExtent.getWidth();
    double scaleY = screenSize.getHeight() / mapExtent.getHeight();

    double tx = -mapExtent.getMinX() * scaleX;
    double ty = (mapExtent.getMinY() * scaleY) + screenSize.getHeight();

    AffineTransform at = new AffineTransform(scaleX, 0.0d, 0.0d, -scaleY, tx, ty);

    return at;
  }
Exemplo n.º 13
0
  protected java.awt.Point adjustDrawPointToViewport(
      int x, int y, java.awt.geom.Rectangle2D bounds, java.awt.Rectangle viewport) {
    if (x + bounds.getMaxX() > viewport.getWidth())
      x = (int) (viewport.getWidth() - bounds.getWidth()) - 1;
    else if (x < 0) x = 0;

    if (y + bounds.getMaxY() > viewport.getHeight())
      y = (int) (viewport.getHeight() - bounds.getHeight()) - 1;
    else if (y < 0) y = 0;

    return new java.awt.Point(x, y);
  }
Exemplo n.º 14
0
    public void paintComponent(Graphics g) {

      Graphics2D g2 = (Graphics2D) g;

      Dimension d = getSize();
      double w = d.getWidth();
      double h = d.getHeight();

      double ew = w;
      double eh = h;

      if (h > PROP * w) {
        eh = PROP * w;
      } else if (w > h / PROP) {
        ew = h / PROP;
      }

      int rw = (int) (ew * 0.80) - 1;
      int rx = (int) (ew - rw) - 1;

      if (left) {
        rx = (int) (w - rx - rw);
      }

      /*
      g.setColor(Color.RED);
      g.drawRect(0,0,(int)w,(int)h-1);
      g.setColor(Color.BLUE);
      g.drawRect(0,0,(int)ew,(int)eh-1);

      g.setColor(Color.BLACK);
      */
      Rectangle s = new Rectangle(rx, 0, rw, (int) (eh * 0.70));
      g2.setColor(background);
      g2.fill(s);
      g2.setColor(Color.BLACK);
      g2.draw(s);

      double ow = eh * 0.25;
      int ox = (int) (rx + (rw - ow) / 2);

      Rectangle o = new Rectangle(ox, (int) (eh * 0.73), (int) ow, (int) ow);
      g2.setColor(background);
      g2.fillOval((int) o.getX(), (int) o.getY(), (int) o.getWidth(), (int) o.getHeight());

      g2.setColor(Color.BLACK);

      g2.drawOval((int) o.getX(), (int) o.getY(), (int) o.getWidth(), (int) o.getHeight());
    }
Exemplo n.º 15
0
 /** Sets the displayed region to the whole board. */
 public void zoom_all() {
   board_panel.board_handling.adjust_design_bounds();
   java.awt.Rectangle display_rect = board_panel.get_viewport_bounds();
   java.awt.Rectangle design_bounds =
       board_panel.board_handling.graphics_context.get_design_bounds();
   double width_factor = display_rect.getWidth() / design_bounds.getWidth();
   double height_factor = display_rect.getHeight() / design_bounds.getHeight();
   double zoom_factor = Math.min(width_factor, height_factor);
   java.awt.geom.Point2D zoom_center =
       board_panel.board_handling.graphics_context.get_design_center();
   board_panel.zoom(zoom_factor, zoom_center);
   java.awt.geom.Point2D new_vieport_center =
       board_panel.board_handling.graphics_context.get_design_center();
   board_panel.set_viewport_center(new_vieport_center);
 }
 @Override
 public boolean isContainedInSelection(Rectangle drawingViewSelection, double scale) {
   FGERectangle drawingViewBounds =
       new FGERectangle(
           drawingViewSelection.getX(),
           drawingViewSelection.getY(),
           drawingViewSelection.getWidth(),
           drawingViewSelection.getHeight(),
           Filling.FILLED);
   boolean isFullyContained = true;
   for (ControlArea<?> ca : getConnector().getControlAreas()) {
     if (ca instanceof ControlPoint) {
       ControlPoint cp = (ControlPoint) ca;
       Point cpInContainerView =
           convertLocalNormalizedPointToRemoteViewCoordinates(
               cp.getPoint(), getDrawingGraphicalRepresentation(), scale);
       FGEPoint preciseCPInContainerView = new FGEPoint(cpInContainerView.x, cpInContainerView.y);
       if (!drawingViewBounds.containsPoint(preciseCPInContainerView)) {
         // System.out.println("Going outside: point="+preciseCPInContainerView+"
         // bounds="+containerViewBounds);
         isFullyContained = false;
       }
     }
   }
   return isFullyContained;
 }
  /**
   * Makes sure the current editor height matches its content if the annotation was never resized.
   * If the annotation has been manually resized before, does nothing.
   *
   * @param anno the annotation currently in the editor
   */
  private void updateEditorHeight(final WorkflowAnnotation anno) {
    if (anno.wasResized()) {
      return;
    }

    Rectangle bounds = editPane.getBounds();
    // height is either the pref height or the current height, depending on what is bigger
    int prefHeight;
    if (anno instanceof ProcessAnnotation) {
      prefHeight =
          (int) Math.max(getContentHeightOfEditor((int) bounds.getWidth()), bounds.getHeight());
    } else {
      prefHeight =
          Math.max(
              getContentHeightOfEditor((int) bounds.getWidth()), OperatorAnnotation.MIN_HEIGHT);
    }
    Rectangle newBounds =
        new Rectangle(
            (int) bounds.getX(), (int) bounds.getY(), (int) bounds.getWidth(), prefHeight);
    if (!bounds.equals(newBounds)) {
      editPane.setBounds(newBounds);
      updateEditPanelPosition(newBounds, true);
      view.getModel().fireAnnotationMiscChanged(anno);
    }
  }
Exemplo n.º 18
0
 private void setSceneRasterStartAndStopTime(Product product) {
   final Product sourceProduct = getSourceProduct();
   final ProductData.UTC startTime = sourceProduct.getStartTime();
   final ProductData.UTC stopTime = sourceProduct.getEndTime();
   final ProductSubsetDef subsetDef = getSubsetDef();
   if (startTime != null
       && stopTime != null
       && subsetDef != null
       && subsetDef.getRegion() != null) {
     final double height = sourceProduct.getSceneRasterHeight();
     final Rectangle region = subsetDef.getRegion();
     final double regionY = region.getY();
     final double regionHeight = region.getHeight();
     final double dStart = startTime.getMJD();
     final double dStop = stopTime.getMJD();
     final double vPerLine = (dStop - dStart) / (height - 1);
     final double newStart = vPerLine * regionY + dStart;
     final double newStop = vPerLine * (regionHeight - 1) + newStart;
     product.setStartTime(new ProductData.UTC(newStart));
     product.setEndTime(new ProductData.UTC(newStop));
   } else {
     product.setStartTime(startTime);
     product.setEndTime(stopTime);
   }
 }
Exemplo n.º 19
0
 // ------------------------------
 public void
     scrollToCaret() { // not called - fixed with putting visible scrollbars on JScrollPane
   //
   Rectangle rect1 = scroller1.getViewport().getViewRect();
   double x1 = rect1.getX();
   double y1 = rect1.getY();
   double r1height = rect1.getHeight();
   double r1width = rect1.getWidth();
   Caret caret1 = editor1.getCaret();
   Point pt2 = caret1.getMagicCaretPosition(); // the end of the string
   double x2 = pt2.getX();
   double y2 = pt2.getY();
   if (((x2 > x1) && (x2 < (x1 + r1width))) && ((y2 > y1) && (y2 < (y1 + r1height)))) {
     // inview
   } else {
     double newheight = r1height / 2;
     double newwidth = r1width / 2;
     double x3 = pt2.getX() - newwidth;
     double y3 = pt2.getY() - newheight;
     if (x3 < 0) x3 = 0;
     if (y3 < 0) y3 = 0;
     Rectangle rect3 = new Rectangle((int) x3, (int) y3, (int) newwidth, (int) newheight);
     editor1.scrollRectToVisible(rect3);
   }
 } // end scrollToCaret
  /** {@inheritDoc } */
  @Override
  public double[] getResolution(final CoordinateReferenceSystem crs) {
    if (CRS.equalsIgnoreMetadata(objectiveCRS, crs)) {
      return getResolution();
    } else {
      final double[] res = new double[crs.getCoordinateSystem().getDimension()];

      final Envelope env;
      try {
        env = CRS.transform(canvasObjectiveBBox2D, crs);
        final Rectangle2D canvasCRSBounds =
            new Rectangle2D.Double(0, 0, env.getSpan(0), env.getSpan(1));
        res[0] = Math.abs(canvasCRSBounds.getWidth() / canvasDisplaybounds.getWidth());
        res[1] = Math.abs(canvasCRSBounds.getHeight() / canvasDisplaybounds.getHeight());
        for (int i = 2; i < res.length; i++) {
          // other dimension are likely to be the temporal and elevation one.
          // we set a hug resolution to ensure that only one slice of data will be retrived.
          res[i] = Double.MAX_VALUE;
        }
      } catch (TransformException ex) {
        LOGGER.log(Level.WARNING, null, ex);
      } catch (IllegalArgumentException ex) {
        LOGGER.log(Level.WARNING, null, ex);
      } catch (Exception ex) {
        LOGGER.log(Level.WARNING, null, ex);
      }

      return adjustResolutionWithDPI(res);
    }
  }
Exemplo n.º 21
0
  /**
   * Calculate the affine transforms used to convert between world and pixel coordinates. The
   * calculations here are very basic and assume a cartesian reference system.
   *
   * <p>Tne transform is calculated such that {@code envelope} will be centred in the display
   *
   * @param envelope the current map extent (world coordinates)
   * @param paintArea the current map pane extent (screen units)
   */
  private void setTransforms(final Envelope envelope, final Rectangle paintArea) {
    ReferencedEnvelope refEnv = null;
    if (envelope != null) {
      refEnv = new ReferencedEnvelope(envelope);
    } else {
      refEnv = worldEnvelope();
      // FIXME content.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
    }

    java.awt.Rectangle awtPaintArea = Utils.toAwtRectangle(paintArea);
    double xscale = awtPaintArea.getWidth() / refEnv.getWidth();
    double yscale = awtPaintArea.getHeight() / refEnv.getHeight();

    double scale = Math.min(xscale, yscale);

    double xoff = refEnv.getMedian(0) * scale - awtPaintArea.getCenterX();
    double yoff = refEnv.getMedian(1) * scale + awtPaintArea.getCenterY();

    worldToScreen = new AffineTransform(scale, 0, 0, -scale, -xoff, yoff);
    try {
      screenToWorld = worldToScreen.createInverse();

    } catch (NoninvertibleTransformException ex) {
      ex.printStackTrace();
    }
  }
  /**
   * Loads the location/size of a frame from the properties file and positions the frame as
   * appropriate.
   *
   * @param frame the frame to position.
   * @param name the name of the property to load from
   */
  public WindowPosition loadFrame(int windowID) {
    if (windowCoords == null) loadConfiguration();

    WindowPosition result = windowCoords.get(windowID);

    if (result
        == null) { // invent default coordinates, using
                   // http://java.sun.com/j2se/1.5.0/docs/api/java/awt/GraphicsDevice.html#getDefaultConfiguration()

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      GraphicsDevice[] gs = ge.getScreenDevices();
      int deviceToUse = Integer.valueOf(getProperty(G_PROPERTIES.GRAPHICS_MONITOR));
      if (deviceToUse >= gs.length)
        deviceToUse =
            statechum.GlobalConfiguration
                .DEFAULT_SCREEN; // use the first one if cannot use the requested one.
      GraphicsConfiguration gc = gs[deviceToUse].getDefaultConfiguration();

      // from http://java.sun.com/j2se/1.4.2/docs/api/index.html
      Rectangle shape = gc.getBounds();
      Rectangle rect = new Rectangle(new Rectangle(shape.x, shape.y, 400, 300));
      if (rect.height > shape.height) rect.height = shape.height;
      if (rect.width > shape.width) rect.width = shape.width;
      rect.y += windowID * (rect.getHeight() + 30);
      int yLimit = shape.height - rect.height;
      if (rect.y > yLimit) rect.y = yLimit;
      int xLimit = shape.width - rect.width;
      if (rect.x > xLimit) rect.x = xLimit;
      result = new WindowPosition(rect, deviceToUse);
      windowCoords.put(windowID, result);
    }

    return result;
  }
Exemplo n.º 23
0
 // ----------------------------------------------------------------
 // Rationing ROI's
 //
 // ----------------------------------------------------------------
 //
 public static void setAcqRoi(Rectangle roi) {
   acqRoi = roi;
   Prefs.usr.putInt("acqRatioRoi_X", (int) acqRoi.getX());
   Prefs.usr.putInt("acqRatioRoi_Y", (int) acqRoi.getY());
   Prefs.usr.putInt("acqRatioRoi_W", (int) acqRoi.getWidth());
   Prefs.usr.putInt("acqRatioRoi_H", (int) acqRoi.getHeight());
 }
Exemplo n.º 24
0
 /**
  * only a short version of toString()
  *
  * @return like S(0) [0,0, 1440x900]
  */
 @Override
 public String toStringShort() {
   Rectangle r = getBounds();
   return String.format(
       "S(%d)[%d,%d %dx%d]",
       curID, (int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
 }
Exemplo n.º 25
0
  public void paintEntityLayer(final int layer, final long timestamp, final Graphics g) {
    final int w = getWidth();
    final int h = getHeight();
    Rectangle gClip = g.getClipBounds();
    TRectangle wClip =
        new TRectangle(
            centerX + (gClip.getMinX() - w / 2) / scale,
            centerY + (gClip.getMinY() - h / 2) / scale,
            gClip.getWidth() / scale,
            gClip.getHeight() / scale);
    plane.eachEntity(
        wClip,
        layer << 1,
        (~layer << 1) & (0x7 << 1),
        new Iterated() {
          /** Position buffer */
          double[] pbuf = new double[3];

          @Override
          public void item(Object o) {
            AWTDrawableEntity e = (AWTDrawableEntity) o;
            e.getPosition(timestamp, pbuf);
            e.draw(
                (Graphics2D) g,
                (float) ((pbuf[0] - centerX) * scale + w / 2),
                (float) ((pbuf[1] - centerY) * scale + h / 2),
                (float) scale,
                (float) e.getRotation(timestamp),
                timestamp,
                layer);
          }
        });
  }
Exemplo n.º 26
0
  public TaskbarPositionTest() {
    super("Use CTRL-down to show a JPopupMenu");
    setContentPane(panel = createContentPane());
    setJMenuBar(createMenuBar("1 - First Menu", true));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // CTRL-down will show the popup.
    panel
        .getInputMap()
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP");
    panel.getActionMap().put("OPEN_POPUP", new PopupHandler());

    pack();

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    fullScreenBounds = new Rectangle(new Point(), toolkit.getScreenSize());
    screenBounds = new Rectangle(new Point(), toolkit.getScreenSize());

    // Place the frame near the bottom. This is a pretty wild guess.
    this.setLocation(0, (int) screenBounds.getHeight() - 2 * this.getHeight());

    // Reduce the screen bounds by the insets.
    GraphicsConfiguration gc = this.getGraphicsConfiguration();
    if (gc != null) {
      Insets screenInsets = toolkit.getScreenInsets(gc);
      screenBounds = gc.getBounds();
      screenBounds.width -= (screenInsets.left + screenInsets.right);
      screenBounds.height -= (screenInsets.top + screenInsets.bottom);
      screenBounds.x += screenInsets.left;
      screenBounds.y += screenInsets.top;
    }

    setVisible(true);
  }
  public void drawImage(
      final Graphics2D g2d,
      final Rectangle2D rectangle2d,
      ReportSubjectLocation location,
      boolean pixelateImages)
      throws KettleException {

    // Load the transformation
    //
    TransMeta transMeta = loadTransformation(location);

    Point min = transMeta.getMinimum();
    Point area = transMeta.getMaximum();
    int iconsize = 32;

    ScrollBarInterface bar =
        new ScrollBarInterface() {
          public void setThumb(int thumb) {}

          public int getSelection() {
            return 0;
          }
        };

    // Paint the transformation...
    //
    Rectangle rect = new java.awt.Rectangle(0, 0, area.x, area.y);
    double magnificationX = rectangle2d.getWidth() / rect.getWidth();
    double magnificationY = rectangle2d.getHeight() / rect.getHeight();
    double magnification = Math.min(magnificationX, magnificationY);

    SwingGC gc = new SwingGC(g2d, rect, iconsize, 0, 0);
    gc.setDrawingPixelatedImages(pixelateImages);

    TransPainter painter =
        new TransPainter(
            gc,
            transMeta,
            area,
            bar,
            bar,
            null,
            null,
            null,
            new ArrayList<AreaOwner>(),
            new ArrayList<StepMeta>(),
            iconsize,
            1,
            0,
            0,
            true,
            "FreeSans",
            10);
    painter.setMagnification((float) Math.min(magnification, 1));
    if (pixelateImages) {
      painter.setTranslationX(100 + min.x);
      painter.setTranslationY(100 + min.y);
    }
    painter.buildTransformationImage();
  }
Exemplo n.º 28
0
  public static BufferedImage rotateImage(BufferedImage image, double theta) {
    int degrees = (int) Math.abs(Math.toDegrees(theta));
    double xCenter = image.getWidth() / 2;
    double yCenter = image.getHeight() / 2;
    AffineTransform rotateTransform = AffineTransform.getRotateInstance(-theta, xCenter, yCenter);

    // Translation adjustments so image still centered after rotate width/height changes
    if (image.getHeight() != image.getWidth() && degrees != 180 && degrees != 0) {
      Point2D origin = new Point2D.Double(0.0, 0.0);
      origin = rotateTransform.transform(origin, null);
      double yTranslate = origin.getY();

      Point2D yMax = new Point2D.Double(0, image.getHeight());
      yMax = rotateTransform.transform(yMax, null);
      double xTranslate = yMax.getX();

      AffineTransform translationAdjustment =
          AffineTransform.getTranslateInstance(-xTranslate, -yTranslate);
      rotateTransform.preConcatenate(translationAdjustment);
    }

    AffineTransformOp op = new AffineTransformOp(rotateTransform, AffineTransformOp.TYPE_BILINEAR);
    // Have to recopy image because of JDK bug #4723021, AffineTransformationOp throwing exception
    // sometimes
    image = copyImage(image, BufferedImage.TYPE_INT_ARGB);

    // Need to create filter dest image ourselves since AffineTransformOp's own dest image creation
    // throws exceptions in some cases.
    Rectangle bounds = op.getBounds2D(image).getBounds();
    BufferedImage finalImage =
        new BufferedImage(
            (int) bounds.getWidth(), (int) bounds.getHeight(), BufferedImage.TYPE_INT_ARGB);

    return op.filter(image, finalImage);
  }
Exemplo n.º 29
0
 private boolean checkLayering(Area b) {
   ArrayList<Number> id = getVisible();
   Vector<Rectangle> rects = new Vector<Rectangle>(id.size());
   for (Number n : id) {
     rects.add(getIE().get(n).toRectangle());
   }
   Rectangle r = b.toRectangle();
   int index = 0;
   for (Rectangle rect : rects) {
     if (r.equals(rect)) {
       index = rects.indexOf(rect) + 1;
     }
   }
   for (int i = index; i < rects.size(); i++) {
     Rectangle rect = rects.get(i);
     if (r.intersects(rect)) {
       Rectangle isect = r.intersection(rect);
       isect.setRect(isect.x, isect.y, isect.getWidth() + 1, isect.getHeight() + 2);
       if (isect.contains(mascot.getAnchor())) {
         return false;
       }
     }
   }
   return true;
 }
Exemplo n.º 30
0
 public Rectangle makeDouble(Rectangle original) {
   // Double the width and height, leave x and y alone.
   return new Rectangle(
       (int) original.getX(),
       (int) original.getY(),
       (int) original.getWidth() * 2,
       (int) original.getHeight() * 2);
 }