Exemple #1
0
  /**
   * Render the View to the given graphic context. This implementation render the interior first,
   * then the outline.
   */
  public void paint(Graphics2D g, Rectangle2D a) {
    if (!a.intersects(getBounds())) return;
    if (image != null) { // paint bitmap
      g.drawImage(image, text2ModelTr, null);
      // debug:
      g.setPaint(Color.red);
      g.draw(this.bounds);
      super.paint(g, a); // possibly paint framebox if non-null
    } else { // paint textlayout
      super.paint(g, a); // possibly paint framebox if non-null

      AffineTransform oldAT = g.getTransform();
      // paint text in black
      g.setPaint(Color.black);
      // from now on, we work in Y-direct (<0) coordinates to avoid inextricable problems with font
      // being mirrored...
      g.transform(text2ModelTr); // also include rotation
      textLayout.draw(g, 0.0f, 0.0f);
      // [pending] ajouter un cadre si areDimensionsComputed (wysiwyg du pauvre)
      // get back to previous transform
      g.setTransform(oldAT);
      if (DEBUG) {
        g.setPaint(Color.red);
        g.draw(bounds);
      }
    }
  }
Exemple #2
0
  public void paintBoard(Graphics2D g2) {

    double gbwidth = boardGridSize * 8d + lineLoc, gbheight = boardGridSize * 9d + lineLoc;
    g2.setPaint(red);
    g2.draw3DRect((int) lineLoc / 2, (int) lineLoc / 2, (int) gbwidth, (int) gbheight, true);
    g2.draw3DRect(
        (int) lineLoc / 2 + 3, (int) lineLoc / 2 + 3, (int) gbwidth - 6, (int) gbheight - 7, false);
    g2.setPaint(fg);
    for (int i = 0; i < 10; i++) {
      g2.draw(
          new Line2D.Double(
              lineLoc,
              lineLoc + boardGridSize * i,
              lineLoc + boardGridSize * 8,
              lineLoc + boardGridSize * i));
    }
    for (int i = 0; i < 9; i++) {
      g2.draw(
          new Line2D.Double(
              lineLoc + boardGridSize * i,
              lineLoc,
              lineLoc + boardGridSize * i,
              lineLoc + boardGridSize * 4));
      if (i == 0 || i == 8)
        g2.draw(
            new Line2D.Double(
                lineLoc + boardGridSize * i,
                lineLoc + boardGridSize * 4,
                lineLoc + boardGridSize * i,
                lineLoc + boardGridSize * 9));
      else
        g2.draw(
            new Line2D.Double(
                lineLoc + boardGridSize * i,
                lineLoc + boardGridSize * 5,
                lineLoc + boardGridSize * i,
                lineLoc + boardGridSize * 9));
    }
    drawX(lineLoc + boardGridSize * 4, lineLoc + boardGridSize, g2);
    drawX(lineLoc + boardGridSize * 4, lineLoc + boardGridSize * 8, g2);
    // black Pao
    drawLocation(lineLoc + boardGridSize, lineLoc + boardGridSize * 2, center, g2);
    drawLocation(lineLoc + boardGridSize * 7, lineLoc + boardGridSize * 2, center, g2);
    // red Pao
    drawLocation(lineLoc + boardGridSize, lineLoc + boardGridSize * 7, center, g2);
    drawLocation(lineLoc + boardGridSize * 7, lineLoc + boardGridSize * 7, center, g2);
    // black Zu
    drawLocation(lineLoc, lineLoc + boardGridSize * 3, right, g2);
    drawLocation(lineLoc + boardGridSize * 2, lineLoc + boardGridSize * 3, center, g2);
    drawLocation(lineLoc + boardGridSize * 4, lineLoc + boardGridSize * 3, center, g2);
    drawLocation(lineLoc + boardGridSize * 6, lineLoc + boardGridSize * 3, center, g2);
    drawLocation(lineLoc + boardGridSize * 8, lineLoc + boardGridSize * 3, left, g2);
    // red bin
    drawLocation(lineLoc, lineLoc + boardGridSize * 6, right, g2);
    drawLocation(lineLoc + boardGridSize * 2, lineLoc + boardGridSize * 6, center, g2);
    drawLocation(lineLoc + boardGridSize * 4, lineLoc + boardGridSize * 6, center, g2);
    drawLocation(lineLoc + boardGridSize * 6, lineLoc + boardGridSize * 6, center, g2);
    drawLocation(lineLoc + boardGridSize * 8, lineLoc + boardGridSize * 6, left, g2);
    // ----------------------------------------------------------------------
  }
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;

    currentX = leftMargin;
    currentY = topMargin;

    // Draw the links

    for (int i = 0; i < linkLines.length; i++) {
      if (weights[i].isActive()) {
        g2.setPaint(weights[i].getColor());
        g2.draw(linkLines[i]);
      }
    }

    g2.setPaint(Color.black);

    // Draw the input neurons
    g2.drawString("Inputs", (float) currentX, (float) currentY);
    currentY += titleSpace;

    for (int i = 0; i < genome.getInputs(); i++) {
      g2.drawImage(inputNeuron, (int) currentX, (int) currentY, null);
      currentY += space;
    }

    // Draw the hidden Neurons
    currentX += space;
    currentY = topMargin;
    g2.drawString("Hidden Layers", (float) currentX, (float) currentY);

    for (int i = 0; i < genome.getHiddenLayers(); i++) {
      currentY = topMargin + titleSpace;
      for (int j = 0; j < genome.getNeuronsInHiddenLayer(); j++) {
        g2.drawImage(hiddenNeuron, (int) currentX, (int) currentY, null);
        currentY += space;
      }
      currentX += space;
    }

    // Draw the output neurons
    currentY = topMargin;
    g2.drawString("Outputs", (float) currentX, (float) currentY);
    currentY += titleSpace;

    for (int i = 0; i < genome.getOutputs(); i++) {
      g2.drawImage(outputNeuron, (int) currentX, (int) currentY, null);
      currentY += space;
    }

    // Draw the links

    for (int i = 0; i < linkLines.length; i++) {
      if (weights[i].isActive()) {
        g2.setPaint(weights[i].getColor());
        g2.draw(linkLines[i]);
      }
    }
  }
  /** This method is invoked before the rendered image of the figure is composited. */
  public void drawFigure(Graphics2D g) {
    AffineTransform savedTransform = null;
    if (get(TRANSFORM) != null) {
      savedTransform = g.getTransform();
      g.transform(get(TRANSFORM));
    }

    if (get(FILL_STYLE) != ODGConstants.FillStyle.NONE) {
      Paint paint = ODGAttributeKeys.getFillPaint(this);
      if (paint != null) {
        g.setPaint(paint);
        drawFill(g);
      }
    }

    if (get(STROKE_STYLE) != ODGConstants.StrokeStyle.NONE) {
      Paint paint = ODGAttributeKeys.getStrokePaint(this);
      if (paint != null) {
        g.setPaint(paint);
        g.setStroke(ODGAttributeKeys.getStroke(this));
        drawStroke(g);
      }
    }
    if (get(TRANSFORM) != null) {
      g.setTransform(savedTransform);
    }
  }
Exemple #5
0
  /**
   * Paints the icon.
   *
   * @param c the component on which it is painted
   * @param _g the graphics context
   * @param x the x coordinate of the icon
   * @param y the y coordinate of the icon
   */
  public void paintIcon(Component c, Graphics _g, int x, int y) {
    Graphics2D g = (Graphics2D) _g;
    AffineTransform at = AffineTransform.getTranslateInstance(x + offsetX, y + offsetY);

    // save current graphics paint and clip
    Paint gPaint = g.getPaint();
    Shape gClip = g.getClip();

    // render shape(s)
    g.setPaint(color);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.clipRect(x, y, w, h);

    // paint shape, if any
    if (shape != null) {
      g.fill(at.createTransformedShape(shape));
    }

    // paint decoration, if any
    if (decoration != null) {
      g.setPaint(decoColor);
      g.fill(at.createTransformedShape(decoration));
    }
    // restore graphics paint and clip
    g.setPaint(gPaint);
    g.setClip(gClip);
  }
 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);
 }
    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);
    }
 private void paintBackgroundPressedAndDefault(Graphics2D g) {
   roundRect = decodeRoundRect1();
   g.setPaint(color17);
   g.fill(roundRect);
   roundRect = decodeRoundRect2();
   g.setPaint(decodeGradient4(roundRect));
   g.fill(roundRect);
   roundRect = decodeRoundRect3();
   g.setPaint(decodeGradient2(roundRect));
   g.fill(roundRect);
 }
 private void paintBackgroundDisabled(Graphics2D g) {
   roundRect = decodeRoundRect1();
   g.setPaint(color25);
   g.fill(roundRect);
   roundRect = decodeRoundRect2();
   g.setPaint(decodeGradient5(roundRect));
   g.fill(roundRect);
   roundRect = decodeRoundRect3();
   g.setPaint(decodeGradient6(roundRect));
   g.fill(roundRect);
 }
 private void paintBackgroundMouseOverAndDefault(Graphics2D g) {
   roundRect = decodeRoundRect5();
   g.setPaint(color1);
   g.fill(roundRect);
   roundRect = decodeRoundRect2();
   g.setPaint(decodeGradient3(roundRect));
   g.fill(roundRect);
   roundRect = decodeRoundRect3();
   g.setPaint(decodeGradient2(roundRect));
   g.fill(roundRect);
 }
 private void paintBackgroundEnabled(Graphics2D g) {
   roundRect = decodeRoundRect1();
   g.setPaint(color1);
   g.fill(roundRect);
   roundRect = decodeRoundRect2();
   g.setPaint(decodeGradient7(roundRect));
   g.fill(roundRect);
   roundRect = decodeRoundRect3();
   g.setPaint(decodeGradient2(roundRect));
   g.fill(roundRect);
 }
 private void paintBackgroundMouseOverAndFocused(Graphics2D g) {
   roundRect = decodeRoundRect4();
   g.setPaint(color9);
   g.fill(roundRect);
   roundRect = decodeRoundRect2();
   g.setPaint(decodeGradient9(roundRect));
   g.fill(roundRect);
   roundRect = decodeRoundRect3();
   g.setPaint(decodeGradient10(roundRect));
   g.fill(roundRect);
 }
 private void paintBackgroundPressedAndFocused(Graphics2D g) {
   roundRect = decodeRoundRect4();
   g.setPaint(color9);
   g.fill(roundRect);
   roundRect = decodeRoundRect2();
   g.setPaint(decodeGradient11(roundRect));
   g.fill(roundRect);
   roundRect = decodeRoundRect3();
   g.setPaint(decodeGradient2(roundRect));
   g.fill(roundRect);
 }
Exemple #14
0
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int w = getWidth();
    int h = getHeight();
    double theta, x, y;

    g2.setPaint(Color.blue);
    double x1 = w * 3 / 24, y1 = h * 3 / 32, x2 = w * 11 / 24, y2 = y1;
    g2.draw(new Line2D.Double(x1, y1, x2, y2));
    // draw this arrow head at point x2, y2 and measure
    // angle theta relative to same point, ie, y2 - and x2 -
    theta = Math.atan2(y2 - y1, x2 - x1);
    drawArrow(g2, theta, x2, y2);

    x1 = w * 3 / 8;
    y1 = h * 13 / 15;
    x2 = w * 2 / 3;
    y2 = y1;
    g2.draw(new Line2D.Double(x1, y1, x2, y2));
    theta = Math.atan2(y1 - y2, x1 - x2);
    drawArrow(g2, theta, x1, y1);

    g2.setPaint(Color.red);
    x1 = w * 3 / 24;
    y1 = h * 4 / 32;
    x2 = x1;
    y2 = h * 18 / 32;
    g2.draw(new Line2D.Double(x1, y1, x2, y2));
    theta = Math.atan2(y2 - y1, x2 - x1);
    drawArrow(g2, theta, x2, y2);

    g2.setPaint(Color.orange);
    x1 = w * 5 / 32;
    y1 = h * 27 / 32;
    x2 = w * 27 / 32;
    y2 = h * 5 / 32;
    g2.draw(new Line2D.Double(x1, y1, x2, y2));
    theta = Math.atan2(y2 - y1, x2 - x1);
    drawArrow(g2, theta, x2, y2);

    g2.setPaint(Color.green.darker());
    x1 = w / 2;
    y1 = h / 2;
    x2 = w * 27 / 32;
    y2 = h * 27 / 32;
    g2.draw(new Line2D.Double(x1, y1, x2, y2));
    theta = Math.atan2(y2 - y1, x2 - x1);
    drawArrow(g2, theta, x2, y2);
  }
 private void paintBackgroundEnabledAndWindowNotFocusedAndWindowMaximized(Graphics2D g) {
   roundRect = decodeRoundRect1();
   g.setPaint(decodeGradient10(roundRect));
   g.fill(roundRect);
   roundRect = decodeRoundRect2();
   g.setPaint(decodeGradient11(roundRect));
   g.fill(roundRect);
   rect = decodeRect1();
   g.setPaint(color4);
   g.fill(rect);
   rect = decodeRect4();
   g.setPaint(color54);
   g.fill(rect);
   rect = decodeRect5();
   g.setPaint(color55);
   g.fill(rect);
   rect = decodeRect8();
   g.setPaint(color56);
   g.fill(rect);
   path = decodePath1();
   g.setPaint(color57);
   g.fill(path);
   path = decodePath2();
   g.setPaint(color58);
   g.fill(path);
 }
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   int w = getWidth();
   int h = getHeight();
   // Draw ordinate.
   g2.draw(new Line2D.Double(Points, Points, Points, h - Points));
   // Draw abcissa.
   g2.draw(new Line2D.Double(Points, h - Points, w - Points, h - Points));
   // Draw labels.
   Font font = g2.getFont();
   FontRenderContext frc = g2.getFontRenderContext();
   LineMetrics lm = font.getLineMetrics("0", frc);
   float sh = lm.getAscent() + lm.getDescent();
   // Ordinate label.
   String s = "Strecke";
   float sy = Points + ((h - 2 * Points) - s.length() * sh) / 2 + lm.getAscent();
   for (int i = 0; i < s.length(); i++) {
     String letter = String.valueOf(s.charAt(i));
     float sw = (float) font.getStringBounds(letter, frc).getWidth();
     float sx = (Points - sw) / 2;
     g2.drawString(letter, sx, sy);
     sy += sh;
   }
   // Abcissa label.
   s = "Datum";
   sy = h - Points + (Points - sh) / 2 + lm.getAscent();
   float sw = (float) font.getStringBounds(s, frc).getWidth();
   float sx = (w - sw) / 2;
   g2.drawString(s, sx, sy);
   // Draw lines.
   double xInc = (double) (w - 2 * Points) / (data.length - 1);
   double scale = (double) (h - 2 * Points) / getMax();
   g2.setPaint(Color.green.darker());
   for (int i = 0; i < data.length - 1; i++) {
     double x1 = Points + i * xInc;
     double y1 = h - Points - scale * data[i];
     double x2 = Points + (i + 1) * xInc;
     double y2 = h - Points - scale * data[i + 1];
     g2.draw(new Line2D.Double(x1, y1, x2, y2));
   }
   // Mark data points.
   g2.setPaint(Color.red);
   for (int i = 0; i < data.length; i++) {
     double x = Points + i * xInc;
     double y = h - Points - scale * data[i];
     g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4));
   }
 }
Exemple #17
0
 public void paint(Graphics g, Shape a) {
   Graphics2D g2 = (Graphics2D) g;
   Rectangle2D abounds = a.getBounds2D();
   AffineTransform saveTransform = g2.getTransform();
   Paint savePaint = g2.getPaint();
   try {
     g2.translate(abounds.getX() - bounds.getX(), abounds.getY() - bounds.getY());
     g2.setPaint(Color.BLACK); // FIXME
     p.paint(g2);
   } finally {
     g2.setTransform(saveTransform);
     g2.setPaint(savePaint);
   }
 }
 private void paintBackgroundEnabledAndWindowNotFocused(Graphics2D g) {
   roundRect = decodeRoundRect1();
   g.setPaint(decodeGradient10(roundRect));
   g.fill(roundRect);
   roundRect = decodeRoundRect2();
   g.setPaint(decodeGradient16(roundRect));
   g.fill(roundRect);
   rect = decodeRect1();
   g.setPaint(color4);
   g.fill(rect);
   path = decodePath4();
   g.setPaint(color72);
   g.fill(path);
 }
Exemple #19
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   Dimension d = getSize();
   Color fg3D = Color.lightGray;
   g2.setPaint(fg3D);
   g2.draw3DRect(0, 0, d.width - 1, d.height - 1, true);
   g2.draw3DRect(3, 3, d.width - 7, d.height - 7, false);
   g2.setPaint(fg);
   test.setBounds(boardGridSize * 4 + 10, boardGridSize * 5 - 20, 100, 50);
   this.add(test);
   paintBoard(g2);
 }
Exemple #20
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);
     }
   }
 }
Exemple #21
0
  /**
   * Erases the ball.
   *
   * @param ballGraphic The graphics object to use.
   */
  public void erase(Graphics2D ballGraphic) {
    double upperLeftX = _position.x - (_pixelWidth / 2);
    double upperLeftY = _position.y - (_pixelHeight / 2);

    ballGraphic.setPaint(Color.WHITE);
    ballGraphic.fillOval((int) upperLeftX, (int) upperLeftY, _pixelWidth, _pixelHeight);
  }
 protected void drawShape(Shape s) {
   if (fillGradient) {
     g2.setPaint(fillGradientObject);
     g2.fill(s);
   } else if (fill) {
     g2.setColor(fillColorObject);
     g2.fill(s);
   }
   if (strokeGradient) {
     g2.setPaint(strokeGradientObject);
     g2.draw(s);
   } else if (stroke) {
     g2.setColor(strokeColorObject);
     g2.draw(s);
   }
 }
Exemple #23
0
    protected void paintComponent(Graphics g) {
      super.paintComponent(g);
      Graphics2D g2 = (Graphics2D) g;
      g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      int w = getWidth();
      int h = getHeight();
      int pointSize = Math.max(Math.min(w, h) / 80, 4);

      double xInc = (double) (w - 2 * PAD) / (MAX_X - 1);
      double scale = (double) (h - 2 * PAD) / MAX_Y;
      // Draw abcissa.
      int tickInc = MAX_X / 10;
      for (int i = 0; i <= MAX_X; i += tickInc) {
        int x = PAD + (int) (i * xInc);
        int y = h - PAD;
        g.drawString(Integer.toString(i), x - 5, y + 20);
        g2.draw(new Line2D.Double(x, y - 5, x, y + 5));
      }
      g2.draw(new Line2D.Double(PAD, h - PAD, w - PAD / 2, h - PAD));
      AffineTransform orig = g2.getTransform();
      g2.rotate(-Math.PI / 2);
      g2.setColor(Color.black);
      g2.drawString("Number of comparisons", -((h + PAD) / 2), PAD / 3);
      g2.setTransform(orig);

      // Draw ordinate.
      tickInc = (h - PAD) / 10;

      for (int i = tickInc; i < h - PAD; i += tickInc) {
        int x = PAD;
        int closest_10 = ((int) (i / scale) / 10) * 10;

        int y = h - PAD - (int) (closest_10 * scale);
        if (y < PAD) break;
        String tickMark = Integer.toString(closest_10);
        int stringLen = (int) g2.getFontMetrics().getStringBounds(tickMark, g2).getWidth();
        g.drawString(tickMark, x - stringLen - 8, y + 5);
        g2.draw(new Line2D.Double(x - 5, y, x + 5, y));
      }
      g2.draw(new Line2D.Double(PAD, PAD / 2, PAD, h - PAD));
      g.drawString("Array Size", (w - PAD) / 2, h - PAD + 40);

      for (int index = 0; index < plot_data.size(); index++) {
        int[] data = plot_data.get(index);

        // Mark data points.
        g2.setPaint(plot_colors.get(index));

        for (int i = 0; i < data.length; i++) {
          double x = PAD + i * xInc;
          double y = h - PAD - scale * data[i];
          g2.fill(new Ellipse2D.Double(x - pointSize / 2, y - pointSize / 2, pointSize, pointSize));
        }

        g2.setFont(textFont);
        int stringHeight =
            (int) g2.getFontMetrics().getStringBounds(plot_names.get(index), g2).getHeight();
        g.drawString(plot_names.get(index), PAD + 20, PAD + (index + 1) * stringHeight);
      }
    }
Exemple #24
0
  /** paint the canvas into a image file of given width and height */
  public void writeToImage(String s, int w, int h) {
    String ext;
    File f;
    try {
      ext = s.substring(s.lastIndexOf(".") + 1);
      f = new File(s);
    } catch (Exception e) {
      System.out.println(e);
      return;
    }
    if (!ext.equals("jpg") && !ext.equals("png")) {
      System.out.println("Cannot write to file: Illegal extension " + ext);
      return;
    }
    boolean opq = true;
    if (theOpaque != null) opq = theOpaque;

    BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    g2.setBackground(Color.white);
    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(1));
    g2.setRenderingHint(
        RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    doBuffer(g2, true, new Rectangle(0, 0, w, h));
    try {
      ImageIO.write(image, ext, f);
    } catch (Exception e) {
      System.out.println(e);
    }
  }
 /** 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 paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    String message = "Hello, World!";

    Font f = new Font("Serif", Font.BOLD, 36);
    g2.setFont(f);

    FontRenderContext context = g2.getFontRenderContext();
    Rectangle2D bounds = f.getStringBounds(message, context);

    double x = (getWidth() - bounds.getWidth()) / 2;
    double y = (getHeight() - bounds.getHeight()) / 2;

    double ascent = -bounds.getY();
    double baseY = y + ascent;

    g2.drawString(message, (int) x, (int) baseY);

    g2.setPaint(Color.LIGHT_GRAY);

    g2.draw(new Line2D.Double(x, baseY, x + bounds.getWidth(), baseY));
    Rectangle2D rect = new Rectangle2D.Double(x, y, bounds.getWidth(), bounds.getHeight());
    g2.draw(rect);
  }
 private void paintBorderEnabled(Graphics2D g) {
   rect = decodeRect7();
   g.setPaint(decodeGradient5(rect));
   g.fill(rect);
   rect = decodeRect8();
   g.setPaint(decodeGradient4(rect));
   g.fill(rect);
   rect = decodeRect9();
   g.setPaint(color10);
   g.fill(rect);
   rect = decodeRect10();
   g.setPaint(color10);
   g.fill(rect);
   rect = decodeRect11();
   g.setPaint(color11);
   g.fill(rect);
 }
  // draws the tree, starting from the given node, in the region with x values
  // ranging
  // from minX to maxX, with y value beginning at y, and next level at y +
  // yIncr.
  private void drawTree(Graphics2D g2, TreeNode<E> t, int minX, int maxX, int y, int yIncr) {
    // skip if empty
    if (t == null) return;

    // compute useful coordinates
    int x = (minX + maxX) / 2;
    int nextY = y + yIncr;

    // draw black lines
    g2.setPaint(Color.black);
    if (t.left != null) {
      int nextX = (minX + x) / 2;
      g2.draw(new Line2D.Double(x, y, nextX, nextY));
    }
    if (t.right != null) {
      int nextX = (x + maxX) / 2;
      g2.draw(new Line2D.Double(x, y, nextX, nextY));
    }

    // measure text
    FontMetrics font = g2.getFontMetrics();
    String text = t.data + "";
    int textHeight = font.getHeight();
    int textWidth = font.stringWidth(text);

    // draw the box around the node
    Rectangle2D.Double box =
        new Rectangle2D.Double(
            x - textWidth / 2 - ARC_PAD,
            y - textHeight / 2 - ARC_PAD,
            textWidth + 2 * ARC_PAD,
            textHeight + 2 * ARC_PAD);
    Color c = new Color(187, 224, 227);
    g2.setPaint(c);
    g2.fill(box);
    // draw black border
    g2.setPaint(Color.black);
    g2.draw(box);

    // draw text
    g2.drawString(text, x - textWidth / 2, y + textHeight / 2);

    // draw children
    drawTree(g2, t.left, minX, x, nextY, yIncr);
    drawTree(g2, t.right, x, maxX, nextY, yIncr);
  }
 private void paintBorderDisabled(Graphics2D g) {
   rect = decodeRect2();
   g.setPaint(decodeGradient1(rect));
   g.fill(rect);
   rect = decodeRect3();
   g.setPaint(decodeGradient2(rect));
   g.fill(rect);
   rect = decodeRect4();
   g.setPaint(color6);
   g.fill(rect);
   rect = decodeRect5();
   g.setPaint(color4);
   g.fill(rect);
   rect = decodeRect6();
   g.setPaint(color4);
   g.fill(rect);
 }
 private void paintBackgroundDisabled(Graphics2D g) {
   roundRect = decodeRoundRect1();
   g.setPaint(decodeGradient1(roundRect));
   g.fill(roundRect);
   roundRect = decodeRoundRect2();
   g.setPaint(decodeGradient12(roundRect));
   g.fill(roundRect);
   rect = decodeRect1();
   g.setPaint(color4);
   g.fill(rect);
   path = decodePath3();
   g.setPaint(color61);
   g.fill(path);
   path = decodePath4();
   g.setPaint(decodeGradient13(path));
   g.fill(path);
 }