コード例 #1
0
 private void pan(final Zoomable dst, final double rx, final double ry, final int dt) {
   if (dst == null) return;
   final RectangularShape src = dst.getZoom();
   zoom(
       dst,
       new Rectangle2D.Double(
           src.getX() + src.getWidth() * rx,
           src.getY() + src.getHeight() * ry,
           src.getWidth(),
           src.getHeight()),
       dt);
 }
コード例 #2
0
 /**
  * Splits a bar into subregions (elsewhere, these subregions will have different gradients applied
  * to them).
  *
  * @param bar the bar shape.
  * @param a the first division.
  * @param b the second division.
  * @param c the third division.
  * @return An array containing four subregions.
  */
 private Rectangle2D[] splitHorizontalBar(RectangularShape bar, double a, double b, double c) {
   Rectangle2D[] result = new Rectangle2D[4];
   double y0 = bar.getMinY();
   double y1 = Math.rint(y0 + (bar.getHeight() * a));
   double y2 = Math.rint(y0 + (bar.getHeight() * b));
   double y3 = Math.rint(y0 + (bar.getHeight() * c));
   result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), bar.getWidth(), y1 - y0);
   result[1] = new Rectangle2D.Double(bar.getMinX(), y1, bar.getWidth(), y2 - y1);
   result[2] = new Rectangle2D.Double(bar.getMinX(), y2, bar.getWidth(), y3 - y2);
   result[3] = new Rectangle2D.Double(bar.getMinX(), y3, bar.getWidth(), bar.getMaxY() - y3);
   return result;
 }
コード例 #3
0
 /**
  * Splits a bar into subregions (elsewhere, these subregions will have different gradients applied
  * to them).
  *
  * @param bar the bar shape.
  * @param a the first division.
  * @param b the second division.
  * @param c the third division.
  * @return An array containing four subregions.
  */
 private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a, double b, double c) {
   Rectangle2D[] result = new Rectangle2D[4];
   double x0 = bar.getMinX();
   double x1 = Math.rint(x0 + (bar.getWidth() * a));
   double x2 = Math.rint(x0 + (bar.getWidth() * b));
   double x3 = Math.rint(x0 + (bar.getWidth() * c));
   result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), x1 - x0, bar.getHeight());
   result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, bar.getHeight());
   result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, bar.getHeight());
   result[3] = new Rectangle2D.Double(x3, bar.getMinY(), bar.getMaxX() - x3, bar.getHeight());
   return result;
 }
コード例 #4
0
ファイル: Runtime.java プロジェクト: RikardLegge/Projects
  void generateBackground(int size) {
    backgroundWidth = 100;
    int spacing = backgroundWidth;
    int id = 0;
    for (int i = 0; i < bounds.getWidth() / spacing; i++) {
      background[id][0] = spacing * (i + 1) - bounds.getWidth() / 2;
      background[id][1] = -bounds.getHeight() / 2;
      background[id][2] = spacing * (i + 1) - bounds.getWidth() / 2;
      background[id][3] = 0;
      background[id][4] = spacing * (i + 1) - bounds.getWidth() / 2;
      background[id][5] = bounds.getHeight();

      background[id][6] = rand.nextInt(3) - 1;
      background[id][7] = rand.nextInt(3) - 1;
      background[id][8] = 1;
      id++;
    }
    for (int i = 0; i < bounds.getHeight() / spacing; i++) {
      background[id][0] = -bounds.getHeight() / 2;
      background[id][1] = spacing * (i + 1) - bounds.getHeight() / 2;
      background[id][2] = 0;
      background[id][3] = spacing * (i + 1) - bounds.getWidth() / 2;
      background[id][4] = bounds.getWidth();
      background[id][5] = spacing * (i + 1) - bounds.getHeight() / 2;

      background[id][6] = rand.nextInt(3) - 1;
      background[id][7] = rand.nextInt(3) - 1;
      background[id][8] = 1;
      id++;
    }
  }
コード例 #5
0
 private void zoom(final Zoomable dst, final Point2D center, final double ratio, final int dt) {
   if (dst == null) return;
   final RectangularShape src = dst.getZoom();
   final double w = src.getWidth() * ratio;
   final double h = src.getHeight() * ratio;
   final double cx, cy;
   if (center == null) {
     cx = src.getCenterX();
     cy = src.getCenterY();
   } else {
     cx = center.getX();
     cy = center.getY();
   }
   zoom(dst, new Rectangle2D.Double(cx - w / 2, cy - h / 2, Math.abs(w), Math.abs(h)), dt);
 }
コード例 #6
0
ファイル: Runtime.java プロジェクト: RikardLegge/Projects
 boolean render(Graphics2D map) {
   double diff = (System.nanoTime() - created) / 1000 / 1000;
   if (diff > timeAlive) return true;
   map.setColor(new Color(100, 100, 100, (int) (255 - (diff / timeAlive * 250))));
   for (int i = 0; i < particles.length; i++) {
     RectangularShape tmp = (RectangularShape) particles[i][0];
     double xD = (Double) particles[i][1];
     double yD = (Double) particles[i][2];
     tmp.setFrame(
         (double) tmp.getX() + xD / delta,
         (double) tmp.getY() + yD / delta,
         tmp.getWidth(),
         tmp.getHeight());
     map.draw(tmp);
   }
   return false;
 }