示例#1
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());
   }
 }
示例#2
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));
    }
  }
  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;
  }
示例#4
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);
  }
  /**
   * Scrolls the map pane image. We use {@linkplain MapPane#moveImage(int, int)} rather than
   * {@linkplain MapPane#setDisplayArea(<any>)} in this method because it gives much smoother
   * scrolling when the key is held down.
   *
   * @param action scroll direction
   */
  private void scroll(Action action) {
    Rectangle r = ((JComponent) mapPane).getVisibleRect();
    if (!(r == null || r.isEmpty())) {
      int dx = 0;
      int dy = 0;
      switch (action) {
        case SCROLL_LEFT:
          dx = Math.max(1, (int) (r.getWidth() * SCROLL_FRACTION));
          break;

        case SCROLL_RIGHT:
          dx = Math.min(-1, (int) (-r.getWidth() * SCROLL_FRACTION));
          break;

        case SCROLL_UP:
          dy = Math.max(1, (int) (r.getWidth() * SCROLL_FRACTION));
          break;

        case SCROLL_DOWN:
          dy = Math.min(-1, (int) (-r.getWidth() * SCROLL_FRACTION));
          break;

        default:
          throw new IllegalArgumentException("Invalid action argument: " + action);
      }

      mapPane.moveImage(dx, dy);
    }
  }
  /**
   * 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);
    }
  }
  /**
   * 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);
  }
示例#8
0
  /**
   * Ecrit le nom de l'element.
   *
   * @param g graphics
   * @param vueElement vue de l'element a dessiner
   * @param coordX abscisse de l'element
   * @param coordY ordonnee de l'element
   * @return vrai si le texte a ete ecrit en dessous de la forme representant l'element, faux sinon
   */
  private boolean dessineElementNom(Graphics g, VueElement<?> vueElement, int coordX, int coordY) {
    Rectangle rect = this.getBounds();

    // affiche au dessus du point ses informations
    String s = vueElement.getElement().getNom();
    int stringWidth = (int) g.getFontMetrics().getStringBounds(s, g).getWidth();
    int stringHeight = (int) g.getFontMetrics().getStringBounds(s, g).getHeight();
    int start = (stringWidth / 2) - (ELEMENT_SIZE / 2);

    // gestion du debordement des infos
    int coordXString = Math.max(coordX - start, 2);

    if (coordXString + stringWidth > rect.getWidth()) {
      coordXString = (int) (rect.getWidth() - 2 - stringWidth);
    }

    int coordYString = coordY - 10;
    boolean descendu = false;

    if (coordY < stringHeight) {
      coordYString = coordY + 29;
      descendu = true;
    }

    g.drawString(s, coordXString, coordYString);

    return descendu;
  }
 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);
         }
       }
     }
   }
 }
    private void recalculateMaxValues() {
      myIdxLeft = widestEditor(myLeftEditors);
      final Editor leftEditor = myLeftEditors.get(myIdxLeft);
      final int wholeWidth = leftEditor.getContentComponent().getWidth();
      final Rectangle va = leftEditor.getScrollingModel().getVisibleArea();
      final int visibleLeft = leftEditor.xyToVisualPosition(new Point(va.width, 0)).column;

      myMaxColumnsLeft = (int) (visibleLeft * ((double) wholeWidth / va.getWidth()));

      myIdxRight = widestEditor(myRightEditors);
      final Editor rightEditor = myRightEditors.get(myIdxRight);
      final int wholeWidthRight = rightEditor.getContentComponent().getWidth();
      final Rectangle vaRight = rightEditor.getScrollingModel().getVisibleArea();
      final int visibleRight = rightEditor.xyToVisualPosition(new Point(va.width, 0)).column;

      myMaxColumnsRight = (int) (visibleRight * ((double) wholeWidthRight / vaRight.getWidth()));

      myByLeft = !(myMaxColumnsLeft <= visibleLeft);
      if (!myByLeft) {
        // check right editor
        if (myLeftScroll.getVisibleAmount() != visibleRight) {
          myLeftScroll.setVisibleAmount(visibleRight);
        }
        myLeftScroll.setMaximum(myMaxColumnsRight);
      } else {
        if (myLeftScroll.getVisibleAmount() != visibleLeft) {
          myLeftScroll.setVisibleAmount(visibleLeft);
        }
        myLeftScroll.setMaximum(myMaxColumnsLeft);
      }
    }
示例#11
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);
 }
示例#12
0
  /**
   * Adjust the size of the shape so it encompasses the text inside it.
   *
   * @return a <code>Rectangle2D</code> that is the bounds of this shape.
   */
  public Rectangle resizeToFitText() {
    Rectangle anchor = getAnchor();
    if (anchor.getWidth() == 0.) throw new POIXMLException("Anchor of the shape was not set.");
    double height = getTextHeight();
    height += 1; // add a pixel to compensate rounding errors

    anchor.setRect(anchor.getX(), anchor.getY(), anchor.getWidth(), height);
    setAnchor(anchor);

    return anchor;
  }
  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);
  }
示例#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());
    }
示例#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);
 }
示例#16
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());
 }
示例#17
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);
  }
示例#18
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();
    }
  }
  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();
  }
示例#20
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);
    }
  }
示例#22
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());
 }
示例#23
0
  private static void showOnScreen(int screen, JFrame frame, boolean fullscreen) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gd = ge.getScreenDevices();
    if (!Main.protection || (screen > -1 && screen < gd.length)) {
      if (!Main.protection || (fullscreen && screen == Main.secondScreen)) {
        // frame.setSize(gd[screen].getDefaultConfiguration().getBounds().x,gd[screen].getDefaultConfiguration().getBounds().y);
        gd[screen].setFullScreenWindow(frame);
      } else {
        frame.setSize(600, 300);
        Rectangle bound = gd[screen].getDefaultConfiguration().getBounds();
        System.out.println(
            "x: "
                + bound.x
                + " y: "
                + bound.y
                + " width: "
                + bound.width
                + " height : "
                + bound.height);
        frame.setLocation((int) (bound.x + bound.getWidth() / 2 - 300), frame.getY());
      }

      return;
    }
    System.out.println("Erreur : l'ecran " + screen + " n'a pas ete trouve");
  }
示例#24
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;
 }
示例#25
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);
  }
示例#26
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);
          }
        });
  }
 @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;
 }
示例#28
0
 private void setGraphicsCenter(Graphics2D graphics2D, SpriteLocation center) {
   Rectangle screen = graphics2D.getClipBounds();
   SpriteLocation screenCenter =
       new SpriteLocation(
           screen.getX() + screen.getWidth() * 0.5, screen.getY() + screen.getHeight() * 0.5);
   center = screenCenter.sub(center);
   graphics2D.translate(center.getX(), center.getY());
 }
示例#29
0
 /**
  * interactive region create with given message: lets the user draw the rectangle using the mouse
  *
  * @return the region
  */
 public Region selectRegion(final String msg) {
   ScreenImage sim = userCapture(msg);
   if (sim == null) {
     return null;
   }
   Rectangle r = sim.getROI();
   return Region.create((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
 }
示例#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);
 }