Esempio n. 1
0
  public void mouseDragged(MouseEvent evt) {
    Graphics g = canvas.getGraphics();
    g.setColor(color);

    if (type == 0) {
      g.setXORMode(canvas.getBackground());
      g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);
      end = evt.getPoint();
      g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);
    } else if (type == 1) {
      int radius;

      g.setXORMode(canvas.getBackground());

      radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));

      g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);
      end = evt.getPoint();

      radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));

      g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);
    } else if (type == 2) {
      g.setXORMode(canvas.getBackground());
      g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y);
      end = evt.getPoint();
      g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y);
    }
  }
Esempio n. 2
0
  public void mouseReleased(MouseEvent evt) {
    Graphics g = canvas.getGraphics();
    g.setColor(color);
    g.setPaintMode();
    end = evt.getPoint();

    if (type == 0) {
      g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);

      if (filled.getState() == true) g.fillRect(start.x, start.y, end.x - start.x, end.y - start.y);

      status.setText("2. Ecke des Rechtecks festgelegt");
    } else if (type == 1) {
      int radius;

      radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));

      g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);

      if (filled.getState() == true)
        g.fillOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);

      status.setText("Radius des Kreises festgelegt");
    } else if (type == 2) {
      g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y);

      if (filled.getState() == true) g.fillOval(start.x, start.y, end.x - start.x, end.y - start.y);

      status.setText("Radius der Ellipse festgelegt");
    }
  }
Esempio n. 3
0
  /** Overrides <code>Graphics.drawOval</code>. */
  public void drawOval(int x, int y, int width, int height) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info().log(toShortString() + " Drawing oval: " + new Rectangle(x, y, width, height));
    }
    if (isDrawingBuffer()) {
      if (debugBuffered()) {
        Graphics debugGraphics = debugGraphics();

        debugGraphics.drawOval(x, y, width, height);
        debugGraphics.dispose();
      }
    } else if (debugFlash()) {
      Color oldColor = getColor();
      int i, count = (info.flashCount * 2) - 1;

      for (i = 0; i < count; i++) {
        graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
        graphics.drawOval(x, y, width, height);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
      graphics.setColor(oldColor);
    }
    graphics.drawOval(x, y, width, height);
  }
Esempio n. 4
0
  public void render(Graphics g) {
    double time = getTime() - startTime;

    int w = getWidth();
    int h = getHeight();

    int x = 200;
    int y = 100;

    g.setColor(Color.white);
    g.fillRect(0, 0, w, h);

    g.setColor(Color.green);
    g.drawOval(x, y, 100, 100); // head
    g.fillOval(x, y, 100, 100); // head
    g.drawOval(x + 80, y, 100, 100); // big nose
    g.fillOval(x + 80, y, 100, 100); // big nose
    g.drawOval(x + 40, y - 35, 30, 60); // eyes
    g.fillOval(x + 40, y - 35, 30, 60); // eyes
    //      g.drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
    /*
    g.setColor(Color.green);
    g.drawRect(x+30, y+85, 55, 37);
    g.fillRect(x+30, y+85, 55, 37);

    g.drawArc(x-100, y+48, 185, 150, 0, -130);
    g.fillArc(x-100, y+48, 185, 150, 25, -155);

    g.setColor(Color.white);
    g.drawArc(x-150, y+12, 180, 170, 0, -95);
    g.fillArc(x-150, y+12, 180, 170, 0, -95);  */

    //      drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
    g.setColor(Color.black);
    int bodyStartX = x + 31;
    int bodyStartY = y + 95;

    int[] bodyXs = {
      bodyStartX,
      bodyStartX - 10,
      bodyStartX - 20,
      bodyStartX - 30,
      bodyStartX - 40,
      bodyStartX - 45
    };
    int[] bodyYs = {
      bodyStartY,
      bodyStartY + 20,
      bodyStartY + 40,
      bodyStartY + 60,
      bodyStartY + 70,
      bodyStartY + 75
    };

    g.drawPolygon(bodyXs, bodyYs, 6);
  }
Esempio n. 5
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    g.drawOval(5, 5, getWidth() / 2 - 10, getHeight() / 2 - 10);
    g.setColor(Color.red);
    g.drawOval(getWidth() / 2 + 5, 5, getWidth() / 2 - 10, getHeight() / 2 - 10);
    g.setColor(Color.yellow);
    g.fillOval(5, getHeight() / 2 + 5, getWidth() / 2 - 10, getHeight() / 2 - 10);
    g.setColor(Color.orange);
    g.fillOval(getWidth() / 2 + 5, getHeight() / 2 + 5, getWidth() / 2 - 10, getHeight() / 2 - 10);
  }
Esempio n. 6
0
  public void paintComponent(Graphics g) {

    // HEADER CONTROL
    g.drawString("Name", 20, 40);
    g.drawOval(130, 20, 75, 30);
    g.drawString("Me", 160, 40);
    g.drawOval(230, 20, 75, 30);
    g.drawString("Other", 250, 40);
    g.drawOval(330, 20, 75, 30);
    g.drawString("Win", 360, 40);
    g.drawOval(430, 20, 75, 30);
    g.drawString("Loose", 450, 40);
  }
Esempio n. 7
0
  @Override
  public void draw(Graphics g) {
    g.setColor(Color.GREEN);
    g.fillOval(vakje.getPosX() * 25 + 6, vakje.getPosY() * 25, 11, 11);
    g.setColor(Color.BLACK);
    g.drawOval(vakje.getPosX() * 25 + 6, vakje.getPosY() * 25, 11, 11);

    g.setColor(Color.RED);
    g.fillOval(vakje.getPosX() * 25, vakje.getPosY() * 25 + 12, 11, 11);
    g.setColor(Color.BLACK);
    g.drawOval(vakje.getPosX() * 25, vakje.getPosY() * 25 + 12, 11, 11);
    g.fillOval(vakje.getPosX() * 25 + 12, vakje.getPosY() * 25 + 12, 11, 11);
    g.setColor(Color.BLACK);
    g.drawOval(vakje.getPosX() * 25 + 12, vakje.getPosY() * 25 + 12, 11, 11);
  }
Esempio n. 8
0
 /**
  * Draw character in minimap
  *
  * @param g Graphics
  * @param Dx X Displacement
  * @param Dy Y Displacement
  */
 public void MapDraw(Graphics g, int Dx, int Dy, double Scale, Color col) {
   // Color
   g.setColor(col.darker().darker().darker());
   g.drawOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7);
   g.setColor(col);
   g.fillOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7);
 }
    private void displayTree(Graphics g, AVLTree.TreeNode root, int x, int y, int gap) {
      if (root != null) {
        // Display root
        if (setOfHighlightedNodes.contains(root)) {
          g.setColor(Color.GREEN);
          g.fillOval(x - radius, y - radius, 2 * radius, 2 * radius);
          g.setColor(Color.BLACK);
        } else {
          g.drawOval(x - radius, y - radius, 2 * radius, 2 * radius);
        }

        g.drawString(root.element + "", x - 6, y + 4);

        // Draw a line to the left node
        if (root.left != null) connectLeftChild(g, x - gap, y + virticalGap, x, y);

        // Draw left subtree
        displayTree(g, root.left, x - gap, y + virticalGap, gap / 2);

        // Draw a line to the right node
        if (root.right != null) connectRightChild(g, x + gap, y + virticalGap, x, y);

        // Draw right subtree
        displayTree(g, root.right, x + gap, y + virticalGap, gap / 2);
      }
    }
Esempio n. 10
0
    @Override
    public void paintComponent(Graphics g) {
      super.paintComponent(g);

      AnAction action = getAction();
      if (action instanceof ActivateCard) {
        Rectangle bounds = getBounds();

        Icon icon = AllIcons.Actions.Forward; // AllIcons.Icons.Ide.NextStepGrayed;
        int y = (bounds.height - icon.getIconHeight()) / 2;
        int x = bounds.width - icon.getIconWidth() - 15;

        if (getPopState() == POPPED) {
          final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
          g.setColor(WelcomeScreenColors.CAPTION_BACKGROUND);
          g.fillOval(x - 3, y - 3, icon.getIconWidth() + 6, icon.getIconHeight() + 6);

          g.setColor(WelcomeScreenColors.GROUP_ICON_BORDER_COLOR);
          g.drawOval(x - 3, y - 3, icon.getIconWidth() + 6, icon.getIconHeight() + 6);
          config.restore();
        } else {
          icon = IconLoader.getDisabledIcon(icon);
        }

        icon.paintIcon(this, g, x, y);
      }
    }
Esempio n. 11
0
  public void draw(Graphics g) {
    Point pnt = getCenter();

    g.setColor(new Color(255, 213, 0));
    g.drawOval((int) pnt.getX(), (int) pnt.getY(), 5, 5);
    g.fillOval((int) pnt.getX(), (int) pnt.getY(), 5, 5);
  }
Esempio n. 12
0
  /**
   * Function: drawNode Pre: Takes a graphics object g to draw on. Also takes two ints (x_size,
   * y_size) defining the screen size Also takes a node radius r Post: Prints out this node to the
   * screen appropriately
   */
  public void drawNode(Graphics g, int x_size, int y_size, int r) {
    // Don't print nodes that aren't activated
    if (!activated) return;

    // First, get some stats based on the Graphics area size
    // In particular, the size of the Node
    int px = (int) (x_size * x) - r; // X & Y positions
    int py = (int) (y_size * y) - r;

    // Set the font to appropriate no matter what
    // int sizor;    //The size for the text, based on radius
    g.setFont(new Font("Serif", Font.BOLD, r));

    // Find the color for the text, it's used often... we'll do this later now
    // String textcol = getOtherTextColor(color);  MOOF!  UPDATE THIS LATER!
    // Make sure the color is correct no matter what... adjust also later!

    // Node insides... get this color correct later, moof!
    g.setColor(getMyJavaColor());
    // g.setColor(Color.white);
    g.fillOval(px, py, r * 2, r * 2);

    // Node border
    g.setColor(getJavaColor(getOtherNodeColor(color)));
    g.drawOval(px, py, r * 2, r * 2);

    // Text inside... set up to be centered
    py = py + r + (int) (g.getFontMetrics().getAscent() / 2.2);
    px = px + r - (g.getFontMetrics().stringWidth("" + cindex) / 2);
    g.drawString("" + cindex, px, py);
  }
Esempio n. 13
0
  public void draw(Graphics g) {
    animate();

    g.setColor(Color.black);
    g.fillRect(0, 0, dim.width, dim.height);
    g.setColor(Color.white);

    numpaint++;
    DebugPrinter dbg = new DebugPrinter(g, 50, 60);
    dbg.print(
        "Spring-mass demo by yigal irani, drag balls or create new ones by clicking inside box");
    dbg.print("frame", numpaint);
    dbg.print("fps", 1 / timer.time_diff);

    Point top_left = point_by_vec(new Vec(-1, 1));
    g.draw3DRect(top_left.x, top_left.y, screen_dist(2), screen_dist(2), true);
    for (int i = 0; i < springs.size(); i++) {
      Spring spring = springs.get2(i);
      Point p1 = point_by_vec(balls.get2(spring.start).pos);
      Point p2 = point_by_vec(balls.get2(spring.end).pos);
      g.drawLine(p1.x, p1.y, p2.x, p2.y);
    }
    for (int i = 0; i < balls.size(); i++) {
      Ball ball = balls.get2(i);
      Point p = point_by_vec(ball.pos);
      int screen_radius = screen_dist(RADIUS);
      g.setColor(Color.blue);
      g.fillOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.setColor(Color.white);
      g.drawOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.drawString("" + i, p.x, p.y);
    }
  }
 public void draw(Graphics g) {
   Rectangle r = displayBox();
   g.setColor(Color.yellow);
   g.fillOval(r.x, r.y, r.width, r.height);
   g.setColor(Color.black);
   g.drawOval(r.x, r.y, r.width, r.height);
 }
  public void paint(Graphics page) {
    final int MAX_DIAMETER = 50, MAX_CIRCLES = 10, MAX_X = 350, MAX_Y = 250;
    int x, y, diameter, BigX = 0, LDiameter = 0;

    Random generator = new Random();
    setBackground(Color.black);

    for (int count = 1; count < MAX_CIRCLES; count++) {
      // generates the random location of the circles.
      x = generator.nextInt(MAX_X) + 1;
      y = generator.nextInt(MAX_Y) + 1;

      // Generates the random diameter of each circle.
      diameter = generator.nextInt(MAX_DIAMETER) + 1;
      // Draws the 10 random circles
      page.setColor(Color.white);
      page.drawOval(x, y, diameter, diameter);
      // stores the biggest circles location
      if (diameter > LDiameter) {
        BigX = x;
        LDiameter = diameter;
      }
    }
    // Re-colors the biggest circle RED
    page.setColor(Color.red);
    page.fillOval(BigX, MAX_DIAMETER - LDiameter, LDiameter, LDiameter);
  }
 public void paint(Graphics g) {
   g.drawRect(x[0], y[0], 40, 40);
   g.fillRect(x[1], y[1], 20, 20);
   g.drawLine(x[2], y[2], x[3], y[3]);
   g.drawOval(x[4], y[4], 20, 30);
   g.drawString("Moveing", x[5], y[5]);
 }
Esempio n. 17
0
 /**
  * Draws a Circle object on the GrapherPanel as a series of 1 pixel wide lines contained in the
  * Circle's sides variable.
  *
  * @param The Circle to paint.
  */
 private void paintCircle(Circle c) {
   g.setColor(Color.GREEN);
   g.drawOval(
       (int) (c.getCenter().getX() - c.getRadius()),
       (int) (c.getCenter().getY() - c.getRadius()),
       (int) (c.getRadius() * 2),
       (int) (c.getRadius() * 2));
 }
 @Override
 public void draw(Graphics g, Rectangle viewport, double zoom, int offsetX, int offsetY) {
   g.drawOval(
       (int) ((rect.x - viewport.x) * zoom) + offsetX,
       (int) ((rect.y - viewport.y) * zoom) + offsetY,
       (int) (originalRect.width * zoom),
       (int) (originalRect.height * zoom));
 }
 private void paintCircle(Graphics canvas, int i) {
   if (isFill[i]) {
     canvas.setColor(Color[i]);
     canvas.fillOval(X[i], Y[i], circleDiameter, circleDiameter);
   } else {
     canvas.setColor(Color[i]);
     canvas.drawOval(X[i], Y[i], circleDiameter, circleDiameter);
   }
 }
Esempio n. 20
0
 // Een methode die de inhoud van het scherm tekent.
 public void paint(Graphics g) {
   int x = 100, y = 100, l = 10, b = 10;
   for (int teller = 0; teller < 5; teller++) {
     g.drawOval(x, y, l, b);
     x -= 10;
     y -= 10;
     l += 20;
     b += 20;
   }
 }
    /**
     * Draws X and O's
     */
    protected void paintComponent(Graphics g) {

      super.paintComponent(g);
      if (token == 'X') {
        g.drawLine(10, 10, getWidth() - 10, getHeight() - 10);
        g.drawLine(10, getHeight() - 10, getWidth() - 10, 10);
      } else if (token == 'O') {
        g.drawOval(10, 10, getWidth() - 20, getHeight() - 20);
      }
    }
Esempio n. 22
0
 public void paint(Graphics g) {
   g.drawString("Hello", 40, 40);
   setBackground(Color.white);
   g.fillRect(130, 30, 100, 80);
   g.drawOval(30, 130, 50, 60);
   setForeground(Color.red);
   g.fillOval(130, 130, 50, 60);
   g.drawArc(30, 200, 40, 50, 90, 60);
   g.fillArc(50, 200, 40, 20, 180, 40);
 }
 @Override
 public void paint(Graphics g) {
   g.setColor(Color.red);
   double deltaX = x - x1;
   double deltaY = y - y1;
   int r = (int) Math.sqrt(deltaX * deltaX + deltaY * deltaY);
   if (x != -1) {
     // g.fillOval(x - r, y - r, r * 2, r * 2);
     g.drawOval(x - r, y - r, r * 2, r * 2);
   }
 }
Esempio n. 24
0
  private void drawCircle(Graphics g, int x, int y, int diameter, Color backgroundColor) {
    // Correct the diameter to account for drawing artifacts
    int correctedDiameter = diameter - 1;

    // draw circle background
    g.setColor(backgroundColor);
    g.fillOval(x, y, correctedDiameter, correctedDiameter);

    // draw outline
    g.setColor(Color.black);
    g.drawOval(x, y, correctedDiameter, correctedDiameter);
  }
Esempio n. 25
0
  public void paint(Graphics g) {

    int xy = 10;
    int grootte = 500;

    for (int i = 0; i < 100; i++) {

      g.drawOval(xy, xy, grootte, grootte);

      grootte -= 5;
    }
  }
Esempio n. 26
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   g.setColor(Color.GREEN);
   g.drawString("Round" + count, 10, 10);
   for (int i = 0; i < array.length; i++) {
     for (int j = 0; j < array[i].length; j++) {
       if (array[i][j] == 0) {
         g.setColor(Color.ORANGE);
         g.drawOval(j * 10 + 5, i * 10 + 15, 10, 10);
         g.fillOval(j * 10 + 5, i * 10 + 15, 10, 10);
       } else g.setColor(Color.RED);
       g.drawOval(j * 10 + 5, i * 10 + 15, 10, 10);
       g.fillOval(j * 10 + 5, i * 10 + 15, 10, 10);
     }
   }
   g.setColor(Color.BLUE);
   if (stateMes.length() > 13) {
     g.drawString(stateMes.substring(0, 13), 10, array.length * 10 + 30);
     g.drawString(stateMes.substring(14, stateMes.length()), 10, array.length * 10 + 40);
   } else g.drawString(stateMes, 10, array.length * 10 + 30);
   repaint();
 }
Esempio n. 27
0
 /**
  * ************************************************************\ Drawing method for the molecule
  * editor panel *
  *
  * @param g * \*************************************************************
  */
 public void draw(Graphics g) {
   double r = type.getRadius();
   Color c = type.getColor();
   g.setColor(c);
   int pixelsPerNm = DrawPanel.PIXELS_PER_NM;
   // In the drawPanel we map the z-coordinate to the x-coordinate
   int xint = (int) Math.round(pixelsPerNm * z);
   int yint = (int) Math.round(pixelsPerNm * y);
   int rint = (int) Math.round(pixelsPerNm * r);
   g.fillOval(xint - rint, yint - rint, 2 * rint, 2 * rint);
   g.setColor(Color.GRAY);
   g.drawOval(xint - rint, yint - rint, 2 * rint, 2 * rint);
 }
Esempio n. 28
0
  private void drawPageIndicator(Graphics g)
        //  PRE:  g must be initialized.
        //  POST: Draws a page indicator above the OK button. The filled in circle represents which
        //        page we're currently on.
      {
    int x1; // First x coordinate for drawing area.
    int y1; // First y coordinate for drawing area.
    int x2; // Second x coordinate for drawing area.
    int y2; // Second y coordinate for drawing area.
    int width; // Width of drawing area.
    int height; // Height of drawing area.
    int offset; // Offset between circles.
    Graphics2D g2; // Graphics2D to change brush stroke.

    x1 = ScaledPoint.scalerToX(0.275);
    x2 = ScaledPoint.scalerToX(0.325);
    y1 = ScaledPoint.scalerToY(0.85);
    y2 = ScaledPoint.scalerToY(0.89);

    width = (x2 - x1) / 2;
    height = y2 - y1;

    offset = ScaledPoint.scalerToX(0.005) / 2;

    g2 = (Graphics2D) g;

    g2.setColor(Color.WHITE);
    g2.setStroke(new BasicStroke(1));

    if (currentPage == 0) // if we are on the first page
    {
      g.fillOval(x1 - offset, y1, width, height);
      g.drawOval(x1 + width + offset, y1, width, height);
    } else // if we are on the second page.
    {
      g.drawOval(x1 - offset, y1, width, height);
      g.fillOval(x1 + width + offset, y1, width, height);
    }
  }
Esempio n. 29
0
  public void paint(Graphics g) {

    g.setColor(Color.BLACK);
    g.setColor(Color.WHITE);
    g.fillRect(50, 100, 400, 200);
    g.setColor(Color.WHITE);
    g.fillOval(350, 50, 150, 100);
    g.setColor(Color.BLACK);
    g.drawOval(350, 50, 150, 100);
    g.fillRect(360, 300, 10, 50);
    g.fillRect(80, 300, 10, 50);
    g.fillRect(50, 300, 10, 50);
    g.fillRect(440, 300, 10, 50);
  }
Esempio n. 30
0
  public void Draw() {
    Graphics g;
    Color cl;
    int c;
    int xdiff, ydiff;

    g = parentarea.screen;
    if ((Resize) || (ResizeAll)) Calculate_Coors();

    c = ((int) activation) * 255 / 100;
    if (c < 0) c = 0;
    if (c > 255) c = 255;
    cl = new Color(c, c, c);

    if (oldclamp != clamp) {
      g.setColor(Color.white);
      g.fillRect(sx1, sy1, 1 + sx2 - sx1, 1 + sy2 - sy1);
    }

    g.setColor(cl);
    g.fillOval(sx1, sy1, sx2 - sx1, sy2 - sy1);
    g.setColor(Color.black);
    if (activation == (double) 100.0) g.setColor(Color.red);
    g.drawOval(sx1, sy1, sx2 - sx1, sy2 - sy1);

    if (clamp) {
      xdiff = (sx2 - sx1);
      ydiff = (sy2 - sy1);
      g.drawRect(sx1, sy1, xdiff, ydiff);
    }

    if ((Resize) || (ResizeAll)) CalculateSize(g);
    g.setFont(currfont);
    if (activation > 50.0) g.setColor(Color.black);
    else g.setColor(Color.white);
    if (foreground != null) g.setColor(foreground);
    g.drawString(short_name, sx1 + xoff, sy2 - yoff);
    Redraw = false;
    Resize = false;
    if (oldclamp != clamp) {
      // draw all bonds - as they will have been erased
      oldclamp = clamp;
      for (int x = 0; x < outgoing_links.size(); x++) {
        slipnet_link s = (slipnet_link) outgoing_links.elementAt(x);
        s.Draw();
      }
    }
  }