Beispiel #1
0
  public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2D = (Graphics2D) g;
    int x = this.getWidth();
    int y = this.getHeight();
    int z = 4;

    if (orientation.equals(DesktopBar.WEST)) {
      int[] X = {x - z, x - z, 2 * x / 5, x / 2, z, x / 2, 2 * x / 5};
      int[] Y = {2 * y / 5, 3 * y / 5, 3 * y / 5, y - z, y / 2, z, 2 * y / 5};
      g2D.draw(new Polygon(X, Y, 7));
    }
    if (orientation.equals(DesktopBar.EAST)) {
      int[] X = {z, z, 2 * x / 3, x / 2, x - z, x / 2, 2 * x / 3};
      int[] Y = {2 * y / 5, 3 * y / 5, 3 * y / 5, y - z, y / 2, z, 2 * y / 5};
      g2D.draw(new Polygon(X, Y, 7));
    }
    if (orientation.equals(DesktopBar.NORTH)) {
      int[] X = {2 * x / 5, 3 * x / 5, 3 * x / 5, x - z, x / 2, z, 2 * x / 5};
      int[] Y = {y - z, y - z, 2 * y / 5, y / 2, z, y / 2, 2 * y / 5};
      g2D.draw(new Polygon(X, Y, 7));
    }
    if (orientation.equals(DesktopBar.SOUTH)) {
      int[] X = {2 * x / 5, 3 * x / 5, 3 * x / 5, x - z, x / 2, z, 2 * x / 5};
      int[] Y = {z, z, 2 * y / 3, y / 2, y - z, y / 2, 2 * y / 3};
      g2D.draw(new Polygon(X, Y, 7));
    }
  }
Beispiel #2
0
  public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2d = (Graphics2D) g;

    g2d.draw(
        new Ellipse2D.Double(
            centerx - (centery - 500),
            centery - (centery - 500),
            2 * (centery - 500),
            2 * (centery - 500)));

    try {
      g2d.draw(
          new Ellipse2D.Double(
              player.x - player.size / 2, player.y - player.size / 2, player.size, player.size));
    } catch (NullPointerException e) {
    }

    k = 1;
    while (k <= ballCount) {

      g2d.draw(
          new Ellipse2D.Double(
              ball[k].x - ball[k].size / 2,
              ball[k].y - ball[k].size / 2,
              ball[k].size,
              ball[k].size));
      k++;
    }
  }
Beispiel #3
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;

    g2.setStroke(new BasicStroke(wl));
    g2.setColor(color);
    switch (type) {
      case 1:
        {
          g2.draw(new Rectangle2D.Float(wl, wl, getWidth() - 2 * wl, getHeight() - 2 * wl));
          break;
        }
      case 2:
        {
          g2.draw(new Ellipse2D.Float(wl, wl, getWidth() - 2 * wl, getHeight() - 2 * wl));
          break;
        }
      case 3:
        {
          g2.draw(
              new RoundRectangle2D.Float(
                  wl, wl, getWidth() - 2 * wl, getHeight() - 2 * wl, 10, 10));
          break;
        }
      case 4:
        {
          g2.draw(new Line2D.Float(wl, wl, getWidth(), getHeight()));
          break;
        }
    }
  }
Beispiel #4
0
  public void paint(Graphics g) {
    super.paint(g);

    Graphics2D g2 = (Graphics2D) g;
    int size =
        Math.min(
            MAX_SIZE,
            Math.min(
                getWidth() - imagePadding.left - imagePadding.right,
                getHeight() - imagePadding.top - imagePadding.bottom));

    g2.translate(getWidth() / 2 - size / 2, getHeight() / 2 - size / 2);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    Shape shape;

    if (mode == ColorPicker.SAT || mode == ColorPicker.BRI) {
      shape = new Ellipse2D.Float(0, 0, size, size);
    } else {
      Rectangle r = new Rectangle(0, 0, size, size);
      shape = r;
    }

    if (hasFocus()) {
      PaintUtils.paintFocus(g2, shape, 5);
    }

    if (!(shape instanceof Rectangle)) {
      // paint a circular shadow
      g2.translate(2, 2);
      g2.setColor(new Color(0, 0, 0, 20));
      g2.fill(new Ellipse2D.Float(-2, -2, size + 4, size + 4));
      g2.setColor(new Color(0, 0, 0, 40));
      g2.fill(new Ellipse2D.Float(-1, -1, size + 2, size + 2));
      g2.setColor(new Color(0, 0, 0, 80));
      g2.fill(new Ellipse2D.Float(0, 0, size, size));
      g2.translate(-2, -2);
    }

    g2.drawImage(image, 0, 0, size, size, 0, 0, size, size, null);

    if (shape instanceof Rectangle) {
      Rectangle r = (Rectangle) shape;
      PaintUtils.drawBevel(g2, r);
    } else {
      g2.setColor(new Color(0, 0, 0, 120));
      g2.draw(shape);
    }

    g2.setColor(Color.white);
    g2.setStroke(new BasicStroke(1));
    g2.draw(new Ellipse2D.Float(point.x - 3, point.y - 3, 6, 6));
    g2.setColor(Color.black);
    g2.draw(new Ellipse2D.Float(point.x - 4, point.y - 4, 8, 8));

    g.translate(-imagePadding.left, -imagePadding.top);
  }
  public void paint(Graphics g) {
    System.out.println("paint");
    Graphics2D g2d = (Graphics2D) g;

    Point1 p1, p2;

    n = paintInfo.size();

    if (toolFlag == 2) g2d.clearRect(0, 0, getSize().width - 100, getSize().height - 100); // 清除

    for (int i = 0; i < n - 1; i++) {
      p1 = (Point1) paintInfo.elementAt(i);
      p2 = (Point1) paintInfo.elementAt(i + 1);
      size = new BasicStroke(p1.boarder, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

      g2d.setColor(p1.col);
      g2d.setStroke(size);

      if (p1.tool == p2.tool) {
        switch (p1.tool) {
          case 0: // 画笔
            Line2D line1 = new Line2D.Double(p1.x, p1.y, p2.x, p2.y);
            g2d.draw(line1);
            break;

          case 1: // 橡皮
            g.clearRect(p1.x, p1.y, p1.boarder, p1.boarder);
            break;

          case 3: // 画直线
            Line2D line2 = new Line2D.Double(p1.x, p1.y, p2.x, p2.y);
            g2d.draw(line2);
            break;

          case 4: // 画圆
            Ellipse2D ellipse =
                new Ellipse2D.Double(p1.x, p1.y, Math.abs(p2.x - p1.x), Math.abs(p2.y - p1.y));
            g2d.draw(ellipse);
            break;

          case 5: // 画矩形
            Rectangle2D rect =
                new Rectangle2D.Double(p1.x, p1.y, Math.abs(p2.x - p1.x), Math.abs(p2.y - p1.y));
            g2d.draw(rect);
            break;

          case 6: // 截断,跳过
            i = i + 1;
            break;

          default:
        } // end switch
      } // end if
    } // end for
  }
 /** Draws the edge structure of the tree */
 public void drawEdges(Graphics2D gg) {
   gg.setPaint(Color.black);
   Enumeration nodeList = argument.getBreadthFirstTraversal().elements();
   // For each vertex...
   while (nodeList.hasMoreElements()) {
     // Get its edge list...
     TreeVertex vertex = (TreeVertex) nodeList.nextElement();
     Enumeration edges = vertex.getEdgeList().elements();
     // For each edge in the list...
     while (edges.hasMoreElements()) {
       TreeEdge edge = (TreeEdge) edges.nextElement();
       // If we have several vertices on layer 0, only draw
       // edges for layers below that
       if (!(argument.isMultiRoots() && vertex.getLayer() == 0)) {
         // If the edge has been selected with the mouse,
         // use a thick line
         if (edge.isSelected()) {
           gg.setStroke(selectStroke);
         }
         gg.draw(edge.getShape(this));
         // If we used a thick line, reset the stroke to normal
         // line for next edge.
         if (edge.isSelected()) {
           gg.setStroke(solidStroke);
         }
         TreeVertex edgeSource = edge.getDestVertex();
       }
     }
   }
 }
 public void drawTo(Graphics g, Line line) {
   if (!calc.tileOnMap(t1) || !calc.tileOnMap(t2)) return;
   if (calc.tileOnMap(line.getTile1()) && calc.tileOnMap(line.getTile2())) {
     Point p1 = calc.tileToMinimap(t1);
     Point p2 = calc.tileToMinimap(t2);
     Point p3 = calc.tileToMinimap(line.getTile2());
     Point p4 = calc.tileToMinimap(line.getTile1());
     GeneralPath path = new GeneralPath();
     path.moveTo(p1.x, p1.y);
     path.lineTo(p2.x, p2.y);
     path.lineTo(p3.x, p3.y);
     path.lineTo(p4.x, p4.y);
     path.closePath();
     g.setColor(POLY_FILL);
     ((Graphics2D) g).fill(path);
     ((Graphics2D) g).draw(path);
   }
   Point last = null, p;
   g.setColor(Color.ORANGE);
   for (RSTile t : pathList) {
     if (calc.tileOnMap(t)) {
       p = calc.tileToMinimap(t);
       g.fillOval(p.x - 2, p.y - 2, 5, 5);
       if (last != null) g.drawLine(p.x, p.y, last.x, last.y);
       last = p;
     } else last = null;
   }
 }
  private void drawSelection(Graphics2D g2d) {
    if (srcx != destx || srcy != desty) {
      int x1 = (srcx < destx) ? srcx : destx;
      int y1 = (srcy < desty) ? srcy : desty;
      int x2 = (srcx > destx) ? srcx : destx;
      int y2 = (srcy > desty) ? srcy : desty;

      rectSelection.x = x1;
      rectSelection.y = y1;
      rectSelection.width = (x2 - x1) + 1;
      rectSelection.height = (y2 - y1) + 1;
      if (rectSelection.width > 0 && rectSelection.height > 0) {
        g2d.drawImage(scr_img.getSubimage(x1, y1, x2 - x1 + 1, y2 - y1 + 1), null, x1, y1);
      }

      g2d.setColor(selFrameColor);
      g2d.setStroke(bs);
      g2d.draw(rectSelection);
      int cx = (x1 + x2) / 2;
      int cy = (y1 + y2) / 2;
      g2d.setColor(selCrossColor);
      g2d.setStroke(_StrokeCross);
      g2d.drawLine(cx, y1, cx, y2);
      g2d.drawLine(x1, cy, x2, cy);

      if (Screen.getNumberScreens() > 1) {
        drawScreenFrame(g2d, srcScreenId);
      }
    }
  }
Beispiel #9
0
 // This method will draw the figure to a graphical context.  Note that only non-null
 // values are drawn and that the predefined draw() method within the Graphics2D class
 // is used to draw the actual chunks.  This method can draw any figure that implements
 // the Shape interface.  For more info, look up Graphics2D and Shape in the Java API
 public void draw(Graphics2D g) {
   for (int i = 0; i < numChunks; i++) {
     if (chunks[i] != null) {
       g.draw(chunks[i]);
     }
   }
 }
Beispiel #10
0
 @Override
 protected void drawStroke(Graphics2D g) {
   if (isClosed()) {
     double grow = AttributeKeys.getPerpendicularDrawGrowth(this);
     if (grow == 0d) {
       g.draw(path);
     } else {
       GrowStroke gs =
           new GrowStroke(grow, AttributeKeys.getStrokeTotalWidth(this) * get(STROKE_MITER_LIMIT));
       g.draw(gs.createStrokedShape(path));
     }
   } else {
     g.draw(getCappedPath());
   }
   drawCaps(g);
 }
Beispiel #11
0
 public void paintComponent(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   Rectangle2D rect = new Rectangle2D.Double(0, 0, getWidth() - 1, getHeight() - 1);
   g2.setPaint(Color.YELLOW);
   g2.fill(rect);
   g2.setPaint(Color.BLUE);
   g2.draw(rect);
 }
Beispiel #12
0
  public void paintComponent(Graphics g) {
    // необходиом чтобы текст коректно отрисовывался в окне
    super.paintComponent(g);
    // рисуем текст в окне
    Graphics2D g2 = (Graphics2D) g;
    AffineTransform t = g2.getTransform();
    g.drawString("It is text", 5, 5);
    // создание шрифта
    Font f = new Font("SanasSerif", Font.ITALIC, 20);
    g2.setFont(f);
    g2.drawString("It is new text", 5, 33);
    String[] fontNames =
        GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
    for (int i = 5; i < 20; i++) {
      g2.rotate(-0.05);
      g2.setColor(
          new Color(
              (int) (Math.random() * 255),
              (int) (Math.random() * 255),
              (int) (Math.random() * 255)));
      Font f1 = new Font(fontNames[i], Font.BOLD, 20);
      g2.setFont(f1);
      g2.drawString(fontNames[i], 5, 20 * i);
    }
    // текст в центре

    g2.setTransform(t); // возращение к кординатам, которые запонилив начале
    Font f2 = new Font("SanasSerif", Font.ITALIC, 20);
    g2.setFont(f2);
    String s = "It is center!";
    FontRenderContext context = g2.getFontRenderContext();
    Rectangle2D r = f2.getStringBounds(s, context);
    double x1 = (getWidth() - r.getWidth()) / 2;
    double y1 = (getHeight() - r.getHeight()) / 2;
    double ascent = -r.getY(); // узнаем высоту текста
    double y2 = y1 + ascent;
    Rectangle2D rect = new Rectangle2D.Double(x1, y1, r.getWidth(), r.getHeight());
    g2.setColor(Color.YELLOW);
    g2.fill(rect);
    g2.setColor(Color.red);
    g2.drawString(s, (int) x1, (int) y2);
    g2.setColor(Color.blue);
    g2.draw(new Line2D.Double(x1, y2, x1 + r.getWidth(), y2));

    g2.draw(rect);
  }
Beispiel #13
0
  /**
   * Draws the building
   *
   * @param g2 the graphics context
   */
  public void draw(Graphics2D g2) {
    Rectangle building1 = new Rectangle(xLeft, yTop + 30, 10, 30);
    // Rectangle building2 = new Rectangle (xLeft, yTop +23,6,23);
    // Rectangle building3 = new Rectangle (xLeft, yTop +32,12,42);

    g2.draw(building1);
    // g2.draw(building2);
    // g2.draw(building3);
  }
Beispiel #14
0
    public void draw(Graphics2D g2) {
      g2.setPaint(selected ? selColor : bgColor);
      g2.fill(rect);
      // g2.fill(new Rectangle2D.Double(row,col,10,10));
      // g2.fill(new Rectangle2D.Double(rect.x,rect.y,rect.height, rect.width));
      g2.setPaint(color);

      g2.draw(rect);
    }
Beispiel #15
0
 /**
  * Draw a polygon with the given (x[i], y[i]) coordinates.
  *
  * @param x an array of all the x-coordindates of the polygon
  * @param y an array of all the y-coordindates of the polygon
  */
 public static void polygon(double[] x, double[] y) {
   int N = x.length;
   GeneralPath path = new GeneralPath();
   path.moveTo((float) scaleX(x[0]), (float) scaleY(y[0]));
   for (int i = 0; i < N; i++) path.lineTo((float) scaleX(x[i]), (float) scaleY(y[i]));
   path.closePath();
   offscreen.draw(path);
   draw();
 }
Beispiel #16
0
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2d = ((Graphics2D) g);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    g2d.setRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    g2d.setRenderingHint(
        RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
    g2d.setRenderingHint(
        RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
    g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
    g2d.setColor(Color.BLACK);
    g2d.fillRect(0, 0, getWidth(), getHeight());

    if (bufferedImage != null) {
      synchronized (LOCKER) {
        g2d.drawImage(bufferedImage, transformCells, null);
      }
    }
    // draw struct preview
    if (structurePreview != null) {
      Composite composite = g2d.getComposite();
      g2d.setComposite(compositeStructPreview);
      g2d.drawImage(structurePreview, previewTransform, null);
      g2d.setComposite(composite);
    }
    // draw grid
    if (transformCells.getScaleX() > SHOW_GRID_MIN_SCALE) {
      Composite composite = g2d.getComposite();
      g2d.setComposite(compositeGrid);
      g2d.drawImage(bufferedImageGrid, transformGrid, null);
      g2d.setComposite(composite);
    }
    // draw border for preview
    if (structurePreview != null && Math.abs(transformCells.getScaleX()) >= 0.95) {
      Shape shape = new Rectangle(0, 0, structurePreview.getWidth(), structurePreview.getHeight());
      shape = previewTransform.createTransformedShape(shape);
      g2d.setColor(Color.RED);
      g2d.draw(shape);
    }

    // draw border
    double x = transformCells.getTranslateX();
    double y = transformCells.getTranslateY();

    g2d.setColor(BORDER_COLOR);
    g2d.setStroke(new BasicStroke(BORDER_WIDTH));
    g2d.drawRect(
        round(x - BORDER_WIDTH),
        round(y - BORDER_WIDTH),
        round(getAutomatonWidth() * transformCells.getScaleX() + 2 * BORDER_WIDTH),
        round(getAutomatonHeight() * transformCells.getScaleY() + 2 * BORDER_WIDTH));
  }
Beispiel #17
0
 /**
  * Draw a square of side length 2r, centered on (x, y).
  *
  * @param x the x-coordinate of the center of the square
  * @param y the y-coordinate of the center of the square
  * @param r radius is half the length of any side of the square
  * @throws RuntimeException if r is negative
  */
 public static void square(double x, double y, double r) {
   if (r < 0) throw new RuntimeException("square side length can't be negative");
   double xs = scaleX(x);
   double ys = scaleY(y);
   double ws = factorX(2 * r);
   double hs = factorY(2 * r);
   if (ws <= 1 && hs <= 1) pixel(x, y);
   else offscreen.draw(new Rectangle2D.Double(xs - ws / 2, ys - hs / 2, ws, hs));
   draw();
 }
Beispiel #18
0
 /**
  * Draw a circle of radius r, centered on (x, y).
  *
  * @param x the x-coordinate of the center of the circle
  * @param y the y-coordinate of the center of the circle
  * @param r the radius of the circle
  * @throws RuntimeException if the radius of the circle is negative
  */
 public static void circle(double x, double y, double r) {
   if (r < 0) throw new RuntimeException("circle radius can't be negative");
   double xs = scaleX(x);
   double ys = scaleY(y);
   double ws = factorX(2 * r);
   double hs = factorY(2 * r);
   if (ws <= 1 && hs <= 1) pixel(x, y);
   else offscreen.draw(new Ellipse2D.Double(xs - ws / 2, ys - hs / 2, ws, hs));
   draw();
 }
Beispiel #19
0
 /**
  * Draw a rectangle of given half width and half height, centered on (x, y).
  *
  * @param x the x-coordinate of the center of the rectangle
  * @param y the y-coordinate of the center of the rectangle
  * @param halfWidth is half the width of the rectangle
  * @param halfHeight is half the height of the rectangle
  * @throws RuntimeException if halfWidth or halfHeight is negative
  */
 public static void rectangle(double x, double y, double halfWidth, double halfHeight) {
   if (halfWidth < 0) throw new RuntimeException("half width can't be negative");
   if (halfHeight < 0) throw new RuntimeException("half height can't be negative");
   double xs = scaleX(x);
   double ys = scaleY(y);
   double ws = factorX(2 * halfWidth);
   double hs = factorY(2 * halfHeight);
   if (ws <= 1 && hs <= 1) pixel(x, y);
   else offscreen.draw(new Rectangle2D.Double(xs - ws / 2, ys - hs / 2, ws, hs));
   draw();
 }
Beispiel #20
0
 /**
  * Draw an ellipse with given semimajor and semiminor axes, centered on (x, y).
  *
  * @param x the x-coordinate of the center of the ellipse
  * @param y the y-coordinate of the center of the ellipse
  * @param semiMajorAxis is the semimajor axis of the ellipse
  * @param semiMinorAxis is the semiminor axis of the ellipse
  * @throws RuntimeException if either of the axes are negative
  */
 public static void ellipse(double x, double y, double semiMajorAxis, double semiMinorAxis) {
   if (semiMajorAxis < 0) throw new RuntimeException("ellipse semimajor axis can't be negative");
   if (semiMinorAxis < 0) throw new RuntimeException("ellipse semiminor axis can't be negative");
   double xs = scaleX(x);
   double ys = scaleY(y);
   double ws = factorX(2 * semiMajorAxis);
   double hs = factorY(2 * semiMinorAxis);
   if (ws <= 1 && hs <= 1) pixel(x, y);
   else offscreen.draw(new Ellipse2D.Double(xs - ws / 2, ys - hs / 2, ws, hs));
   draw();
 }
Beispiel #21
0
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (nodes.get(0) == null) {
      return;
    }
    Graphics2D g2 = (Graphics2D) g;
    g2.setColor(Color.blue);
    int x = 0;
    int y = 0;
    double xs = (double) (this.getWidth() - b - (nodes.get(0).r * nodeScaling));
    double ys = (double) (this.getHeight() - b - (nodes.get(0).r * nodeScaling) - noticeBorder);
    g2.setColor(Color.black);
    g2.fillRect(0, 0, this.getWidth(), this.getHeight());
    g2.setColor(Color.blue);
    drawNode s;
    drawNode d;
    RenderingHints rh =
        new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);
    g2.setColor(Color.white);
    if (!ignoreLinks) {
      for (drawLink L : links.values()) {
        g2.setColor(L.color);
        s = nodes.get(L.sid);
        d = nodes.get(L.eid);
        if (s != null && d != null) {
          g2.drawLine(
              (int) ((s.x * xs) + (s.r * nodeScaling) / 2d),
              (int) ((s.y * ys) + (s.r * nodeScaling) / 2d),
              (int) ((d.x * xs) + (d.r * nodeScaling) / 2d),
              (int) ((d.y * ys) + (d.r * nodeScaling) / 2d));
        }
      }
    }
    for (drawNode N : nodes.values()) {
      g2.setColor(N.color);
      g2.fill(new Ellipse2D.Double(N.x * xs, N.y * ys, N.r * nodeScaling, N.r * nodeScaling));
      g2.setColor(Color.black);
      g2.draw(new Ellipse2D.Double(N.x * xs, N.y * ys, N.r * nodeScaling, N.r * nodeScaling));
    }
    if (showInfoForNode != -1 && nodeInfo.containsKey(showInfoForNode)) {
      drawNode N = nodes.get(showInfoForNode);

      x = (int) (N.x * xs + N.r * nodeScaling) + 3;
      y = (int) (N.y * ys);
      CTB.flipShift = (int) (N.r * nodeScaling) + 5;
      CTB.draw(g2, x, y, this.getWidth(), this.getHeight(), nodeInfo.get(showInfoForNode));
    }
    g2.setColor(Color.white);
    g2.setFont(new Font("Arial", Font.PLAIN, 10));
    g2.drawString("Ruud van de Bovenkamp - NAS", b, this.getHeight() - b);
    doneDrawing = true;
  }
Beispiel #22
0
  public void drawModel(Graphics2D g2d) {
    for (OriFace face : ORIPA.doc.sortedFaces) {
      if (Globals.modelDispMode == Constants.ModelDispMode.FILL_COLOR) {
        if (face.faceFront) {
          g2d.setColor(new Color(255, 200, 200));
        } else {
          g2d.setColor(new Color(200, 200, 255));
        }
        g2d.fill(face.outline);
      } else if (Globals.modelDispMode == Constants.ModelDispMode.FILL_WHITE) {
        g2d.setColor(Color.WHITE);
        g2d.fill(face.outline);
      } else if (Globals.modelDispMode == Constants.ModelDispMode.FILL_ALPHA) {
        g2d.setColor(new Color(100, 100, 100));
        g2d.fill(face.outline);
      }

      g2d.setColor(Color.BLACK);
      for (OriHalfedge he : face.halfedges) {
        if (he.pair == null) {
          g2d.setStroke(Config.MODEL_STROKE_CUT);
        } else {
          g2d.setStroke(Config.STROKE_CUT);
        }
        g2d.draw(
            new Line2D.Double(
                he.positionForDisplay.x,
                he.positionForDisplay.y,
                he.next.positionForDisplay.x,
                he.next.positionForDisplay.y));
      }
    }

    if (Globals.bDispCrossLine) {
      g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
      g2d.setStroke(Config.MODEL_STROKE_CUT);
      g2d.setColor(Color.RED);

      g2d.draw(new Line2D.Double(crossLine.p0.x, crossLine.p0.y, crossLine.p1.x, crossLine.p1.y));
    }
  }
 public synchronized void paintComponent(Graphics g) // Called on the event dispatch thread
     {
   if (values == null) return;
   Graphics2D g2 = (Graphics2D) g;
   int width = getWidth() / values.length;
   for (int i = 0; i < values.length; i++) {
     double height = values[i] * getHeight();
     Rectangle2D bar = new Rectangle2D.Double(width * i, 0, width, height);
     if (values[i] == marked1 || values[i] == marked2) g2.fill(bar);
     else g2.draw(bar);
   }
 }
 public void draw(Graphics2D g) {
   g.setColor(fillColor);
   g.fill(gp);
   g.setColor(Color.black);
   g.draw(gp);
   for (int i = 0; i < points.size(); i++) {
     GlyphPoint p = points.get(i);
     g.setColor(Color.red);
     g.draw(p.gp);
     g.setColor(Color.blue);
     g.setFont(gfont);
     g.drawString(String.valueOf(i), p.x + 3, p.y + 3);
   }
   g.setColor(Color.black);
   //	    System.out.println("Advance: "+advance);
   g.draw(advp);
   if (name != null) {
     g.setFont(gfont);
     g.drawString(name, 0, -40);
   }
 }
Beispiel #25
0
 /**
  * Draw an arc of radius r, centered on (x, y), from angle1 to angle2 (in degrees).
  *
  * @param x the x-coordinate of the center of the circle
  * @param y the y-coordinate of the center of the circle
  * @param r the radius of the circle
  * @param angle1 the starting angle. 0 would mean an arc beginning at 3 o'clock.
  * @param angle2 the angle at the end of the arc. For example, if you want a 90 degree arc, then
  *     angle2 should be angle1 + 90.
  * @throws RuntimeException if the radius of the circle is negative
  */
 public static void arc(double x, double y, double r, double angle1, double angle2) {
   if (r < 0) throw new RuntimeException("arc radius can't be negative");
   while (angle2 < angle1) angle2 += 360;
   double xs = scaleX(x);
   double ys = scaleY(y);
   double ws = factorX(2 * r);
   double hs = factorY(2 * r);
   if (ws <= 1 && hs <= 1) pixel(x, y);
   else
     offscreen.draw(
         new Arc2D.Double(xs - ws / 2, ys - hs / 2, ws, hs, angle1, angle2 - angle1, Arc2D.OPEN));
   draw();
 }
Beispiel #26
0
 public void paintStroke(Graphics2D g, ButtonInfo info) {
   if (isStrokePainted(info.button)) {
     Paint strokeColor = fill.getStroke(info.button, info.fillBounds);
     g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
     if (isStrokeAntialiased()) {
       g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     } else {
       g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
     }
     g.setPaint(strokeColor);
     g.draw(info.stroke);
   }
 }
Beispiel #27
0
    void draw(Graphics2D g) {

      // toX/toY is tip of arrow and fx/fy is a point on the line -
      // fx/fy is used to determine direction & angle

      AffineTransform at = AffineTransform.getTranslateInstance(toX, toY);
      int b = 9;
      double theta = Math.toRadians(20);
      // The idea of using a GeneralPath is so we can
      // create the (three lines that make up the) arrow
      // (only) one time and then use AffineTransform to
      // place it anywhere we want.
      GeneralPath path = new GeneralPath();

      // distance between line and the arrow mark <** not **
      // Start a new line segment from the position of (0,0).
      path.moveTo(0, 0);
      // Create one of the two arrow head lines.
      int x = (int) (-b * Math.cos(theta));
      int y = (int) (b * Math.sin(theta));
      path.lineTo(x, y);

      // distance between line and the arrow mark <** not **
      // Make the other arrow head line.
      int x2 = (int) (-b * Math.cos(-theta));
      int y2 = (int) (b * Math.sin(-theta));
      // path.moveTo(0,0);
      path.lineTo(x2, y2);
      path.closePath();

      // theta is in radians
      double s, t;
      s = toY - fy; // calculate slopes.
      t = toX - fx;
      if (t != 0) {
        s = s / t;
        theta = Math.atan(s);
        if (t < 0) theta += Math.PI;
      } else if (s < 0) theta = -(Math.PI / 2);
      else theta = Math.PI / 2;

      at.rotate(theta);
      // at.rotate(theta,toX,toY);
      Shape shape = at.createTransformedShape(path);
      if (checkStatus == Status.UNCHECKED) g.setColor(Color.BLACK);
      else if (checkStatus == Status.COMPATIBLE) g.setColor(FOREST_GREEN);
      else g.setColor(ORANGE_RED);
      g.fill(shape);
      g.draw(shape);
    }
 public void draw(
     Graphics2D g,
     Color stringColor,
     Color foreground,
     Color background,
     String info,
     double x,
     double y) {
   FontMetrics fm = g.getFontMetrics();
   int h = fm.getHeight();
   int w = fm.stringWidth(info);
   r1.setRect(
       x - w / 2 - in.left, y - in.top - h / 2, w + in.right + in.left, h + in.bottom + in.top);
   g.setColor(background);
   g.fill(r1);
   g.setColor(stringColor);
   g.draw(r1);
   g.setColor(foreground);
   r2.setRect(r1.getX() + 1, r1.getY() + 1, r1.getWidth() - 2, r1.getHeight() - 2);
   g.draw(r2);
   g.setColor(stringColor);
   g.drawString(
       info, (float) (r2.getX() + in.left), (float) (r2.getY() + h - (r2.getHeight() - h) / 2));
 }
Beispiel #29
0
  public void render(int w, int h, Graphics2D g2) {
    FontRenderContext frc = g2.getFontRenderContext();
    for (int i = 0; i < 2; i++) {
      layouts[i] = new TextLayout(text[i], fonts[i], frc);
      float rw = layouts[i].getAdvance();
      float rh = layouts[i].getAscent() + layouts[i].getDescent();
      float rx = (float) ((w - rw) / 2);
      float ry = (float) ((i == 0) ? h / 3 : h * 0.75f);

      // draw highlighted shape
      Shape hilite = layouts[i].getLogicalHighlightShape(0, curPos[i]);
      AffineTransform at = AffineTransform.getTranslateInstance(rx, ry);
      hilite = at.createTransformedShape(hilite);
      float hy = (float) hilite.getBounds2D().getY();
      float hh = (float) hilite.getBounds2D().getHeight();
      g2.setColor(colors[i]);
      g2.fill(hilite);

      // get caret shape
      Shape[] shapes = layouts[i].getCaretShapes(curPos[i]);
      Shape caret = at.createTransformedShape(shapes[0]);

      g2.setColor(Color.black);
      layouts[i].draw(g2, rx, ry);
      g2.draw(caret);
      g2.draw(new Rectangle2D.Float(rx, hy, rw, hh));

      // Display character advances.
      for (int j = 0; j <= layouts[i].getCharacterCount(); j++) {
        float[] cInfo = layouts[i].getCaretInfo(TextHitInfo.leading(j));
        String str = String.valueOf((int) cInfo[0]);
        TextLayout tl = new TextLayout(str, smallF, frc);
        tl.draw(g2, (float) rx + cInfo[0] - tl.getAdvance() / 2, hy + hh + tl.getAscent() + 1.0f);
      }
    }
  }
 private void drawScreenFrame(Graphics2D g2d, int scrId) {
   g2d.setColor(screenFrameColor);
   g2d.setStroke(strokeScreenFrame);
   if (screenFrame == null) {
     screenFrame = Screen.getBounds(scrId);
     Rectangle ubound = scrOCP.getBounds();
     screenFrame.x -= ubound.x;
     screenFrame.y -= ubound.y;
     int sw = (int) (strokeScreenFrame.getLineWidth() / 2);
     screenFrame.x += sw;
     screenFrame.y += sw;
     screenFrame.width -= sw * 2;
     screenFrame.height -= sw * 2;
   }
   g2d.draw(screenFrame);
 }