public void paint(Graphics g) {
   Graphics2D g_2d = (Graphics2D) g;
   Ellipse2D ellipse = new Ellipse2D.Double(0, 2, 80, 80);
   Rectangle2D rect = new Rectangle2D.Double(40, 2, 80, 80);
   Area a1 = new Area(ellipse);
   Area a2 = new Area(rect);
   a1.intersect(a2); // "Óë"
   g_2d.fill(a1);
   ellipse.setFrame(130, 2, 80, 80);
   rect.setFrame(170, 2, 80, 80);
   a1 = new Area(ellipse);
   a2 = new Area(rect);
   a1.add(a2); // "»ò"
   g_2d.draw(a1);
   ellipse.setFrame(0, 90, 80, 80);
   rect.setFrame(40, 90, 80, 80);
   a1 = new Area(ellipse);
   a2 = new Area(rect);
   a1.subtract(a2); // "²î"
   g_2d.draw(a1);
   ellipse.setFrame(130, 90, 80, 80);
   rect.setFrame(170, 90, 80, 80);
   a1 = new Area(ellipse);
   a2 = new Area(rect);
   a1.exclusiveOr(a2); // "Òì»ò"
   g_2d.fill(a1);
 }
Ejemplo n.º 2
0
 private void setIndicators() {
   if (ellipseIndicator == null) ellipseIndicator = new Ellipse2D.Double();
   if (arcIndicator == null) arcIndicator = new Arc2D.Double();
   ellipseIndicator.setFrame(angle.x, angle.y, angle.width, angle.height);
   arcIndicator.setArc(
       angle.x, angle.y, angle.width, angle.height, angle.start, angle.extent, Arc2D.PIE);
 }
Ejemplo n.º 3
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2 = (Graphics2D) g;

    // draw a rectangle
    double leftX = 100;
    double topY = 100;
    double width = 200;
    double height = 150;

    Rectangle2D rect = new Rectangle2D.Double(leftX, topY, width, height);
    g2.draw(rect);

    // draw a enclosed ellipse
    Ellipse2D ellipse = new Ellipse2D.Double();
    ellipse.setFrame(rect);
    g2.draw(ellipse);

    // draw a diagonal line
    g2.draw(new Line2D.Double(leftX, topY, leftX + width, topY + height));

    // draw a circle with the same center
    double centerX = rect.getCenterX();
    double centerY = rect.getCenterY();
    double radius = 150;

    Ellipse2D circle = new Ellipse2D.Double();
    circle.setFrameFromCenter(centerX, centerY, centerX + radius, centerY + radius);
    g2.draw(circle);
  }
 public void setFrame(int pivoX, int pivoY, int height, int width) {
   this.width = width;
   this.height = height;
   this.pivoX = pivoX;
   this.pivoY = pivoY;
   circle.setFrame(pivoX, pivoX, height, width);
 }
Ejemplo n.º 5
0
    public void paint(Graphics g) {
      g.setColor(Color.gray);

      Graphics2D g2d = (Graphics2D) g;

      Ellipse2D ellipse = new Ellipse2D.Double();
      for (String v : layout.getGraph().getVertices()) {
        Double radius = layout.getRadii().get(v);
        if (radius == null) {
          continue;
        }
        Point2D p = layout.transform(v);
        ellipse.setFrame(-radius, -radius, 2 * radius, 2 * radius);
        AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
        Shape shape = at.createTransformedShape(ellipse);

        MutableTransformer viewTransformer =
            vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);

        if (viewTransformer instanceof MutableTransformerDecorator) {
          shape = vv.getRenderContext().getMultiLayerTransformer().transform(shape);
        } else {
          shape = vv.getRenderContext().getMultiLayerTransformer().transform(Layer.LAYOUT, shape);
        }

        g2d.draw(shape);
      }
    }
Ejemplo n.º 6
0
 /**
  * Calculates the location of the waferedge.
  *
  * @param plotArea the plot area.
  * @return The wafer edge.
  */
 public Ellipse2D getWaferEdge(Rectangle2D plotArea) {
   Ellipse2D edge = new Ellipse2D.Double();
   double diameter = plotArea.getWidth();
   double upperLeftX = plotArea.getX();
   double upperLeftY = plotArea.getY();
   // get major dimension
   if (plotArea.getWidth() != plotArea.getHeight()) {
     double major, minor;
     if (plotArea.getWidth() > plotArea.getHeight()) {
       major = plotArea.getWidth();
       minor = plotArea.getHeight();
     } else {
       major = plotArea.getHeight();
       minor = plotArea.getWidth();
     }
     // ellipse diameter is the minor dimension
     diameter = minor;
     // set upperLeft point
     if (plotArea.getWidth() == minor) { // x is minor
       upperLeftY = plotArea.getY() + (major - minor) / 2;
     } else { // y is minor
       upperLeftX = plotArea.getX() + (major - minor) / 2;
     }
   }
   edge.setFrame(upperLeftX, upperLeftY, diameter, diameter);
   return edge;
 }
Ejemplo n.º 7
0
  protected void moveBall() {
    // System.out.println("I'm in the moveBall() function!");
    int width = getWidth();
    int height = getHeight();
    int min, max, randomX, randomY;
    min = 0;
    max = 200;
    randomX = min + (int) (Math.random() * ((max - min) + 1));
    randomY = min + (int) (Math.random() * ((max - min) + 1));
    // System.out.println(randomX + ", " + randomY);

    Rectangle ballBounds = ball.getBounds();
    //      //System.out.println(ballBounds.x + ", " + ballBounds.y);
    //      if (ballBounds.x + randomX < 0) {
    //          randomX = 200;
    //      } else if (ballBounds.x + ballBounds.width + randomX > width) {
    //          randomX = -200;
    //      }
    //      if (ballBounds.y + randomY < 0) {
    //          randomY = 200;
    //      } else if (ballBounds.y + ballBounds.height + randomY > height) {
    //          randomY = -200;
    //      }

    ballBounds.x = randomX;
    ballBounds.y = randomY;
    _ballXpos = ballBounds.x;
    _ballYpos = ballBounds.y;
    ball.setFrame(ballBounds);
    thePlacebo.repaint();
  }
Ejemplo n.º 8
0
 public void setCoordinate(Point currentP) {
   Ellipse2D tempEllipse = (Ellipse2D) myShape;
   tempEllipse.setFrame(startP.x, startP.y, currentP.x - startP.x, currentP.y - startP.y);
   if (anchorList != null) {
     anchorList.setPosition(myShape.getBounds());
   }
 }
Ejemplo n.º 9
0
 public Ellipse2D evaluate(Ellipse2D v0, Ellipse2D v1, float fraction) {
   double x = v0.getX() + ((v1.getX() - v0.getX()) * fraction);
   double y = v0.getY() + ((v1.getY() - v0.getY()) * fraction);
   double w = v0.getWidth() + ((v1.getWidth() - v0.getWidth()) * fraction);
   double h = v0.getHeight() + ((v1.getHeight() - v0.getHeight()) * fraction);
   Ellipse2D value = (Ellipse2D) v0.clone();
   value.setFrame(x, y, w, h);
   return value;
 }
Ejemplo n.º 10
0
  @Override
  protected void renderElement(
      StyleGroup group, Graphics2D g, Camera camera, GraphicElement element) {
    GraphicNode node = (GraphicNode) element;

    shape.setFrame(node.x - w2, node.y - h2, width, height);
    g.fill(shape);
    renderText(group, g, camera, element);
  }
Ejemplo n.º 11
0
 /** the paintComponent -- paints the board every repaint() call. */
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   for (int i = 0; i < B_WIDTH; i++) {
     for (int j = 0; j < B_HEIGHT; j++) {
       Rectangle2D rect = new Rectangle2D.Double((i * 40) + 1, (j * 40) + 1, 38, 38);
       g2.setPaint(balls[i][j].getColor());
       g2.fill(rect);
       Ellipse2D circle = new Ellipse2D.Double();
       circle.setFrame(rect);
       g2.setPaint(balls[i][j].getcColor());
       g2.fill(circle);
     }
   }
 }
Ejemplo n.º 12
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;

    // Desenarea Dreptunchiului

    double leftX = 100;
    double topY = 100;
    double width = 200;
    double height = 150;

    Rectangle2D rect = new Rectangle2D.Double(leftX, topY, width, height);
    g2.setPaint(Color.RED);
    g2.fill(rect);

    // Desenarea Elipsei, Inclusa in Dreptunghi
    Ellipse2D ellipse = new Ellipse2D.Double();
    ellipse.setFrame(rect);
    // albastru-verde
    g2.setPaint(new Color(0, 128, 128));
    g2.fill(ellipse);
  }
Ejemplo n.º 13
0
  public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // draw a rectangle

    double leftX = 100;
    double topY = 100;
    double width = 200;
    double height = 150;

    Rectangle2D rect = new Rectangle2D.Double(leftX, topY, width, height);
    g2.setPaint(Color.BLACK);
    g2.draw(rect);
    g2.setPaint(Color.RED);
    g2.fill(rect); // Note that the right and bottom edge are not painted
    // over

    // draw the enclosed ellipse

    Ellipse2D ellipse = new Ellipse2D.Double();
    ellipse.setFrame(rect);
    g2.setPaint(new Color(0, 128, 128)); // a dull blue-green
    g2.fill(ellipse);
  }
Ejemplo n.º 14
0
 public SDEllipse(Point p) {
   nshape = new Ellipse2D.Double();
   nshape.setFrame(p.x, p.y, 0, 0);
   shape = nshape;
   setLocation(p);
 }
 public void setHeight(int height) {
   this.height = height;
   circle.setFrame(pivoX, pivoX, this.height, width);
 }
 public void setFrame(int height, int width) {
   this.width = width;
   circle.setFrame(pivoX, pivoX, height, width);
 }
Ejemplo n.º 17
0
 public void setLocation(Point p) {
   nshape.setFrame(p.x, p.y, nshape.getWidth(), nshape.getHeight());
 }
Ejemplo n.º 18
0
 public void setLocation(int x, int y) {
   nshape.setFrame(x, y, nshape.getWidth(), nshape.getHeight());
 }
Ejemplo n.º 19
0
 public void setBounds(int x, int y, int width, int height) {
   nshape.setFrame(x, y, width, height);
 }
Ejemplo n.º 20
0
  @Override
  protected void paintControls(Graphics2D g, ShapeCreationPanel scp) {
    g = (Graphics2D) g.create();

    Rectangle2D r = new Rectangle2D.Float();
    Ellipse2D e = new Ellipse2D.Float();
    Line2D line = new Line2D.Float();
    double z = ((double) scp.getHandleSize()) / 2.0;

    AffineTransform tx = scp.getTransform();

    try {
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g.setColor(Color.black);
      g.setStroke(new BasicStroke(1));

      CubicPath[] paths = getCubicPaths(scp);
      Selection selection = scp.getSelectionModel().getSelection();
      Selection indication = scp.getSelectionModel().getIndication();
      for (int shapeIndex = 0; shapeIndex < paths.length; shapeIndex++) {
        if (scp.getHandlesActive().supports(scp, shapeIndex)) {
          CubicPath path = paths[shapeIndex];

          if (path != null && path.isEmpty() == false) {
            for (int nodeIndex = 0; nodeIndex < path.getNodeCount(); nodeIndex++) {
              Point2D nodePoint = path.getNode(nodeIndex, null);
              nodePoint = tx.transform(nodePoint, null);

              Point2D p = path.getPrevControlForNode(nodeIndex, null);

              if (p != null) {
                p = tx.transform(p, null);

                g.setColor(Color.lightGray);
                line.setLine(nodePoint, p);
                g.draw(line);

                e.setFrame(p.getX() - z, p.getY() - z, 2 * z, 2 * z);

                if (selection.getShapeIndex() == shapeIndex
                    && selection.getNodeIndex() == nodeIndex
                    && Handle.PREVIOUS_CONTROL.equals(selection.getHandle())) {
                  g.setColor(Color.black);
                } else if (indication.getShapeIndex() == shapeIndex
                    && indication.getNodeIndex() == nodeIndex
                    && Handle.PREVIOUS_CONTROL.equals(indication.getHandle())) {
                  g.setColor(Color.gray);
                } else {
                  g.setColor(Color.white);
                }
                g.fill(e);
                g.setColor(Color.black);
                g.draw(e);
              }

              p = path.getNextControlForNode(nodeIndex, null);
              if (p != null) {
                p = tx.transform(p, null);

                g.setColor(Color.lightGray);
                line.setLine(nodePoint, p);
                g.draw(line);

                e.setFrame(p.getX() - z, p.getY() - z, 2 * z, 2 * z);

                if (selection.getShapeIndex() == shapeIndex
                    && selection.getNodeIndex() == nodeIndex
                    && Handle.NEXT_CONTROL.equals(selection.getHandle())) {
                  g.setColor(Color.black);
                } else if (indication.getShapeIndex() == shapeIndex
                    && indication.getNodeIndex() == nodeIndex
                    && Handle.NEXT_CONTROL.equals(indication.getHandle())) {
                } else {
                  g.setColor(Color.white);
                }
                g.fill(e);
                g.setColor(Color.black);
                g.draw(e);
              }

              r.setFrame(nodePoint.getX() - z, nodePoint.getY() - z, 2 * z, 2 * z);

              if (selection.getShapeIndex() == shapeIndex
                  && selection.getNodeIndex() == nodeIndex
                  && Handle.PRIMARY.equals(selection.getHandle())) {
                g.setColor(Color.black);
              } else if (indication.getShapeIndex() == shapeIndex
                  && indication.getNodeIndex() == nodeIndex
                  && Handle.PRIMARY.equals(indication.getHandle())) {
                g.setColor(Color.gray);
              } else {
                g.setColor(Color.white);
              }
              g.fill(r);
              g.setColor(Color.black);
              g.draw(r);
            }
          }
        }
      }
    } finally {
      g.dispose();
    }
  }