@Override
  protected void renderMoveSelectionForCell(Graphics g, int xCell, int yCell, String theMove) {
    int width = g.getClipBounds().width;
    int height = g.getClipBounds().height;
    xCell -= 2;

    String xLetter = coordinateToLetter(xCell);

    String[] moveParts = theMove.split(" ");
    String xTarget = moveParts[5];
    int yTarget = Integer.parseInt(moveParts[6]);
    if (xLetter.equals(xTarget) && yCell == yTarget) {
      g.setColor(Color.BLUE);
      g.drawRect(3, 3, width - 6, height - 6);
      CommonGraphics.fillWithString(g, "X", 3);
    }
    if (moveParts.length > 8) {
      xTarget = moveParts[7];
      yTarget = Integer.parseInt(moveParts[8]);
      if (xLetter.equals(xTarget) && yCell == yTarget) {
        g.setColor(Color.BLUE);
        g.drawRect(3, 3, width - 6, height - 6);
        CommonGraphics.fillWithString(g, "Y", 3);
      }
    }
    if (moveParts.length > 10) {
      xTarget = moveParts[9];
      yTarget = Integer.parseInt(moveParts[10]);
      if (xLetter.equals(xTarget) && yCell == yTarget) {
        g.setColor(Color.BLUE);
        g.drawRect(3, 3, width - 6, height - 6);
        CommonGraphics.fillWithString(g, "Z", 3);
      }
    }
  }
Exemplo n.º 2
0
 /**
  * Paints the bevel image for the specified component with the specified position and size.
  *
  * @param c the component for which this border is being painted
  * @param gr the paint graphics
  * @param x the x position of the painted border
  * @param y the y position of the painted border
  * @param width the width of the painted border
  * @param height the height of the painted border
  */
 public void paintBorder(Component c, Graphics gr, int x, int y, int width, int height) {
   if (image == null) return;
   if (gr.getClipBounds() != null && !gr.getClipBounds().intersects(x, y, width, height)) {
     return;
   }
   paint(c, gr, x, y, width, height, args);
 }
  private void drawComponents(Graphics g) {
    int panelWidth = g.getClipBounds().width;
    int panelHeight = g.getClipBounds().height;

    ((Graphics2D) g)
        .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    drawSteeringWheel(g, panelWidth, panelHeight);
    drawPedals(g, panelWidth, panelHeight);
    drawGear(g, panelWidth, panelHeight);
    drawEngineButton(g, panelWidth, panelHeight);
  }
  @Override
  protected void renderCellForeground(Graphics g, int xCell, int yCell) {
    xCell -= 2;

    if (xCell <= 0 || xCell >= 5) {
      int width = g.getClipBounds().width;
      int height = g.getClipBounds().height;

      g.setColor(Color.DARK_GRAY);
      g.fillRect(0, 0, width, height);
    }
  }
  /**
   * Draws the chart using graphics
   *
   * @param g Graphics to Draw to
   */
  public void drawChart(Graphics g) {
    // Update all chart data
    refreshChartData();

    // Paint the chart
    if (chart != null && g != null)
      chart.draw(
          (Graphics2D) g,
          (Rectangle2D)
              new Rectangle2D.Double(
                  0, 0, g.getClipBounds().getWidth(), g.getClipBounds().getHeight()));
  }
Exemplo n.º 6
0
  public void paintComponent(Graphics g) {
    if (buffer == null
        || g.getClipBounds().width != image.getWidth(null)
        || g.getClipBounds().height != image.getHeight(null)) {
      image = createImage(g.getClipBounds().width, g.getClipBounds().height);
      buffer = image.getGraphics();
    }

    super.paintComponent(g);
    drawBackground_(buffer, g.getClipBounds().width, g.getClipBounds().height);
    drawForeground_(buffer, g.getClipBounds().width, g.getClipBounds().height);
    g.drawImage(image, 0, 0, this);
  }
Exemplo n.º 7
0
 public void paint(Graphics g) {
   g.setColor(new Color(0xFFFFFF));
   g.fillRect(0, 0, g.getClipBounds().width, g.getClipBounds().height);
   g.setColor(new Color(0x000000));
   int width = g.getFontMetrics().stringWidth("Launching Elusiva Everywhere session...");
   int x = (int) (g.getClipBounds().getWidth() / 2) - (width / 2);
   int y = (int) (g.getClipBounds().getHeight() / 2);
   if (!redirectOutput) g.drawString("Launching Elusiva Everywhere session...", x, y);
   width = g.getFontMetrics().stringWidth("Connect to:" + getParameter("server"));
   x = (int) (g.getClipBounds().getWidth() / 2) - (width / 2);
   y = (int) (g.getClipBounds().getHeight() / 2) + 20;
   if (!redirectOutput) g.drawString("Connecting to:" + getParameter("server"), x, y);
 }
Exemplo n.º 8
0
  @Override
  protected final void renderCellBackground(Graphics g, int xCell, int yCell) {
    int width = g.getClipBounds().width;
    int height = g.getClipBounds().height;

    CommonGraphics.drawCellBorder(g);

    // Clear out the edges
    if (xCell == 1 || xCell == 7 || yCell == 1 || yCell == 7) {
      g.setColor(Color.DARK_GRAY);
      g.fillRect(0, 0, width, height);
    }
  }
  /**
   * Paints the word-wrapped text.
   *
   * @param g The graphics context in which to paint.
   * @param a The shape (usually a rectangle) in which to paint.
   */
  public void paint(Graphics g, Shape a) {

    Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a : a.getBounds();
    tabBase = alloc.x;

    Graphics2D g2d = (Graphics2D) g;
    host = (RSyntaxTextArea) getContainer();
    int ascent = host.getMaxAscent();
    int fontHeight = host.getLineHeight();
    FoldManager fm = host.getFoldManager();
    TokenPainter painter = host.getTokenPainter();
    Element root = getElement();

    // Whether token styles should always be painted, even in selections
    int selStart = host.getSelectionStart();
    int selEnd = host.getSelectionEnd();
    boolean useSelectedTextColor = host.getUseSelectedTextColor();

    int n = getViewCount(); // Number of lines.
    int x = alloc.x + getLeftInset();
    tempRect.y = alloc.y + getTopInset();
    Rectangle clip = g.getClipBounds();
    for (int i = 0; i < n; i++) {

      tempRect.x = x + getOffset(X_AXIS, i);
      // tempRect.y = y + getOffset(Y_AXIS, i);
      tempRect.width = getSpan(X_AXIS, i);
      tempRect.height = getSpan(Y_AXIS, i);
      // System.err.println("For line " + i + ": tempRect==" + tempRect);

      if (tempRect.intersects(clip)) {
        Element lineElement = root.getElement(i);
        int startOffset = lineElement.getStartOffset();
        int endOffset = lineElement.getEndOffset() - 1; // Why always "-1"?
        View view = getView(i);
        if (!useSelectedTextColor
            || selStart == selEnd
            || (startOffset >= selEnd || endOffset < selStart)) {
          drawView(painter, g2d, alloc, view, fontHeight, tempRect.y + ascent);
        } else {
          // System.out.println("Drawing line with selection: " + i);
          drawViewWithSelection(
              painter, g2d, alloc, view, fontHeight, tempRect.y + ascent, selStart, selEnd);
        }
      }

      tempRect.y += tempRect.height;

      Fold possibleFold = fm.getFoldForLine(i);
      if (possibleFold != null && possibleFold.isCollapsed()) {
        i += possibleFold.getCollapsedLineCount();
        // Visible indicator of collapsed lines
        Color c = RSyntaxUtilities.getFoldedLineBottomColor(host);
        if (c != null) {
          g.setColor(c);
          g.drawLine(x, tempRect.y - 1, alloc.width, tempRect.y - 1);
        }
      }
    }
  }
Exemplo n.º 10
0
  public void paint(Graphics graphics, long time) {
    // Clear the background.
    Color outsideColor = outsideClipColor.getColor(time);
    Rectangle clip = graphics.getClipBounds();
    graphics.setPaintMode();
    graphics.setColor(outsideColor);
    graphics.fillRect(0, 0, clip.width, clip.height);

    // Draw the sprite in XOR mode.
    OverrideGraphics2D g = new OverrideGraphics2D((Graphics2D) graphics);
    Color insideColor = insideClipColor.getColor(time);
    g.setOverrideXORMode(insideColor);
    sprite.paint(g, time);
    g.setOverrideXORMode(null);

    // Clear the clip area.
    g.setOverrideColor(insideColor);
    clipSprite.paint(g, time);
    g.setOverrideColor(null);

    // Draw the sprite in XOR mode.
    g.setOverrideXORMode(insideColor);
    sprite.paint(g, time);
    g.setOverrideXORMode(null);
  }
Exemplo n.º 11
0
    public @Override void paint(Graphics g) {
      if (!indicatorLabel.getFont().equals(chartFrame.getChartProperties().getFont()))
        indicatorLabel.setFont(chartFrame.getChartProperties().getFont());
      if (!indicatorLabel.getForeground().equals(chartFrame.getChartProperties().getFontColor()))
        indicatorLabel.setForeground(chartFrame.getChartProperties().getFontColor());
      if (!indicatorLabel.getText().equals(indicator.getLabel()))
        indicatorLabel.setText(indicator.getLabel());

      Rectangle oldClip = g.getClipBounds();
      Rectangle newClip = getBounds();
      g.setClip(newClip);

      Graphics2D g2 = (Graphics2D) g.create();

      g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2.setRenderingHint(
          RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
      g2.setRenderingHint(
          RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);

      g2.setPaintMode();

      if (mouseOver) {
        g2.setColor(backColor);
        RoundRectangle2D roundRectangle =
            new RoundRectangle2D.Double(getX(), getY(), getWidth(), getHeight(), 10, 10);
        g2.fill(roundRectangle);
      }

      super.paint(g);

      g2.dispose();
      g.setClip(oldClip);
    }
Exemplo n.º 12
0
  /* (non-Javadoc)
   * @see rendering.Drawable#paint(java.awt.Graphics)
   */
  @Override
  public void paint(Graphics g) {

    Color oldColor = g.getColor();
    Rectangle field = g.getClipBounds();
    g.setColor(color);

    if (autoscale) {
      double[] start = this.plotSheet.toCoordinatePoint(0, 0, field);
      double[] end =
          this.plotSheet.toCoordinatePoint(0, 0 + this.plotSheet.getFrameThickness(), field);

      this.scaleFactor = Math.abs(end[1] - start[1]);
    } else {
      this.scaleFactor = 1.0;
    }

    if (this.isOnFrame) yOffset = plotSheet.getyRange()[0];

    for (int i = 0; i < this.points[0].length; i++) {
      if (points.length == 3) {
        drawBar(
            points[0][i], points[1][i] * scaleFactor * extraScaleFactor, g, field, points[2][i]);
      } else {
        drawBar(points[0][i], points[1][i] * scaleFactor * extraScaleFactor, g, field);
      }
    }

    g.setColor(oldColor);
  }
Exemplo n.º 13
0
 /**
  * Renders using the given rendering surface and area on that surface.
  *
  * @param g the rendering surface to use
  * @param allocation the allocated region to render into
  * @see View#paint
  */
 public void paint(Graphics g, Shape allocation) {
   super.paint(g, allocation);
   Rectangle alloc = allocation.getBounds();
   Rectangle clip = g.getClipBounds();
   // Since listPainter paints in the insets we have to check for the
   // case where the child is not painted because the paint region is
   // to the left of the child. This assumes the ListPainter paints in
   // the left margin.
   if ((clip.x + clip.width) < (alloc.x + getLeftInset())) {
     Rectangle childRect = alloc;
     alloc = getInsideAllocation(allocation);
     int n = getViewCount();
     int endY = clip.y + clip.height;
     for (int i = 0; i < n; i++) {
       childRect.setBounds(alloc);
       childAllocation(i, childRect);
       if (childRect.y < endY) {
         if ((childRect.y + childRect.height) >= clip.y) {
           listPainter.paint(
               g, childRect.x, childRect.y, childRect.width, childRect.height, this, i);
         }
       } else {
         break;
       }
     }
   }
 }
Exemplo n.º 14
0
 public void paintComponent(Graphics g) {
   Rectangle clip = g.getClipBounds();
   Color alphaWhite = new Color(1.0f, 1.0f, 1.0f, 0.65f);
   g.setColor(alphaWhite);
   g.fillRect(clip.x, clip.y, clip.width, clip.height);
   super.paintComponent(g);
 }
Exemplo n.º 15
0
 public void paint(Graphics g) {
   MetalBumps usedBumps;
   if (splitPane.hasFocus()) {
     usedBumps = focusBumps;
     g.setColor(primaryControlColor);
   } else {
     usedBumps = bumps;
     g.setColor(controlColor);
   }
   Rectangle clip = g.getClipBounds();
   Insets insets = getInsets();
   g.fillRect(clip.x, clip.y, clip.width, clip.height);
   Dimension size = getSize();
   size.width -= inset * 2;
   size.height -= inset * 2;
   int drawX = inset;
   int drawY = inset;
   if (insets != null) {
     size.width -= (insets.left + insets.right);
     size.height -= (insets.top + insets.bottom);
     drawX += insets.left;
     drawY += insets.top;
   }
   usedBumps.setBumpArea(size);
   usedBumps.paintIcon(this, g, drawX, drawY);
   super.paint(g);
 }
Exemplo n.º 16
0
  public void paintEntityLayer(final int layer, final long timestamp, final Graphics g) {
    final int w = getWidth();
    final int h = getHeight();
    Rectangle gClip = g.getClipBounds();
    TRectangle wClip =
        new TRectangle(
            centerX + (gClip.getMinX() - w / 2) / scale,
            centerY + (gClip.getMinY() - h / 2) / scale,
            gClip.getWidth() / scale,
            gClip.getHeight() / scale);
    plane.eachEntity(
        wClip,
        layer << 1,
        (~layer << 1) & (0x7 << 1),
        new Iterated() {
          /** Position buffer */
          double[] pbuf = new double[3];

          @Override
          public void item(Object o) {
            AWTDrawableEntity e = (AWTDrawableEntity) o;
            e.getPosition(timestamp, pbuf);
            e.draw(
                (Graphics2D) g,
                (float) ((pbuf[0] - centerX) * scale + w / 2),
                (float) ((pbuf[1] - centerY) * scale + h / 2),
                (float) scale,
                (float) e.getRotation(timestamp),
                timestamp,
                layer);
          }
        });
  }
Exemplo n.º 17
0
  /**
   * Flags processing of output as finished. Updates all stats in the process.
   *
   * @param g graphics context in which processing has finished
   */
  public static void endProcessingOutput(final Graphics g) {
    processOutputTime += System.currentTimeMillis() - startProcessingOutputTime;
    framesProcessed++;

    if (framesProcessed % printResultsFrameRate == 0) {
      if (PDebug.debugPrintFrameRate) {
        System.out.println("Process output frame rate: " + getOutputFPS() + " fps");
        System.out.println("Process input frame rate: " + getInputFPS() + " fps");
        System.out.println("Total frame rate: " + getTotalFPS() + " fps");
        System.out.println();
        resetFPSTiming();
      }

      if (PDebug.debugPrintUsedMemory) {
        System.out.println("Approximate used memory: " + getApproximateUsedMemory() / 1024 + " k");
      }
    }

    if (PDebug.debugRegionManagement) {
      final Graphics2D g2 = (Graphics2D) g;
      g2.setColor(PDebug.getDebugPaintColor());
      g2.fill(g.getClipBounds().getBounds2D());
    }

    processingOutput = false;
  }
Exemplo n.º 18
0
    public void paintIcon(Graphics g) {
      final BufferedImage image =
          new BufferedImage(
              myIcon.getIconWidth(), myIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
      final Graphics2D gg = image.createGraphics();
      myIcon.paintIcon(this, gg, 0, 0);

      final Rectangle bounds = g.getClipBounds();
      int y = myIcon.getIconHeight() - 1;
      while (y < bounds.y + bounds.height) {
        g.drawImage(
            image,
            bounds.x,
            y,
            bounds.x + bounds.width,
            y + 1,
            0,
            myIcon.getIconHeight() - 1,
            bounds.width,
            myIcon.getIconHeight(),
            this);

        y++;
      }

      g.drawImage(image, 0, 0, this);
    }
Exemplo n.º 19
0
  @Override
  protected void renderMoveSelectionForCell(Graphics g, int xCell, int yCell, String theMove) {
    int width = g.getClipBounds().width;
    int height = g.getClipBounds().height;

    String[] moveParts = theMove.split(" ");

    if (moveParts.length == 7) {
      int xTarget = Integer.parseInt(moveParts[4]);
      int yTarget = Integer.parseInt(moveParts[5]);
      if (xTarget == xCell && yCell == yTarget) {
        g.setColor(Color.GREEN);
        g.drawRect(3, 3, width - 6, height - 6);
        g.drawRect(4, 4, width - 8, height - 8);
      }
    }
  }
Exemplo n.º 20
0
 /**
  * Paint each <code>Lite</code> object in turn after testing if it is inside the clip of the
  * Graphics. This is the right way to do it if the repainting time of <code>Lite</code> objects is
  * much greater than the time required to compute its bounds.
  *
  * @see excentric.LiteGroup#paintAll(java.awt.Graphics)
  */
 public void paint(Graphics g) {
   Rectangle clip = g.getClipBounds();
   for (Enumeration e = lites.elements(); e.hasMoreElements(); ) {
     Lite l = (Lite) e.nextElement();
     // if (l.getBounds().intersects(clip))
     l.paint(g);
   }
 }
Exemplo n.º 21
0
 public void paintComponent(Graphics g) {
   Rectangle clipBounds = g.getClipBounds();
   // paint background gray
   g.setColor(backgroundColor);
   g.fillRect(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
   // paint selection box
   super.paintComponent(g);
 }
Exemplo n.º 22
0
 @Override
 public void paint(Graphics g) {
   Rectangle clipBounds = g.getClipBounds();
   paintBackgroundAndFoldingLine(g, clipBounds);
   paintTextColumns(g, clipBounds);
   paintIconRenderers(g, clipBounds);
   paintFoldingArea(g, clipBounds);
 }
Exemplo n.º 23
0
 @Override
 protected void paintComponent(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.65f));
   Rectangle clip = g.getClipBounds();
   g2.fillRect(clip.x, clip.y, clip.width, clip.height);
   g2.dispose();
 }
Exemplo n.º 24
0
  /** Standard override -- draws all the dots. */
  public void paintComponent(Graphics g) {
    // As a JPanel subclass we need call super.paintComponent()
    // so JPanel will draw the white background for us.
    super.paintComponent(g);
    Color origColor = g.getColor();
    for (Line l : lines) {
      if (l.isPencil()) {
        g.setColor(Color.RED);
      } else {
        g.setColor(Color.BLACK);
      }
      g.drawLine((int) l.getX1(), (int) l.getY1(), (int) l.getX2(), (int) l.getY2());
    }
    g.setColor(origColor);

    // Go through all the dots, drawing a circle for each
    for (ManModel dotModel : dots) {
      // g.drawImage(img, dotModel.getX() - MAN_WIDTH/2, dotModel.getY() - MAN_HEIGHT/2, MAN_WIDTH,
      // MAN_HEIGHT, null);
      g.drawImage(
          img,
          dotModel.getX() - Constants.MAN_WIDTH / 2,
          dotModel.getY() - Constants.MAN_HEIGHT / 2,
          null);
    }

    numberMen.setText("" + dots.size());

    // Draw the "requested" clip rect in red
    // (this just shows off smart-repaint)
    if (redPaint) {
      Rectangle clip = g.getClipBounds();
      if (clip != null) {
        g.setColor(Color.red);
        g.drawRect(clip.x, clip.y, clip.width - 1, clip.height - 1);
        g.setColor(origColor);
      }
    }

    g.setColor(Color.RED);
    for (Line l : circles) {
      g.drawLine((int) l.getX1(), (int) l.getY1(), (int) l.getX2(), (int) l.getY2());
    }

    for (Arc l : arcs) {
      g.drawArc(
          (int) l.getX1(),
          (int) l.getY1(),
          (int) l.getWidth(),
          (int) l.getHeight(),
          (int) l.getStartAngle(),
          (int) l.getSweep());
      // g.drawArc((int) l.getX1(), (int) l.getY1(), (int) l.getWidth()+1, (int) l.getHeight()+1,
      // l.getStartAngle()-1, l.getSweep());

    }
    g.setColor(Color.BLACK);
  }
Exemplo n.º 25
0
 public BorderEffect(
     EditorImpl editor, Graphics graphics, int clipStartOffset, int clipEndOffset) {
   myEditor = editor;
   myGraphics = graphics;
   myStartOffset = clipStartOffset;
   myEndOffset = clipEndOffset;
   myRange = new TextRange(myStartOffset, myEndOffset);
   myClipDetector = new ClipDetector(editor, graphics.getClipBounds());
 }
  /**
   * Paints the View.
   *
   * @param g the rendering surface to use
   * @param a the allocated region to render into
   * @see View#paint
   */
  @Override
  public void paint(Graphics g, Shape a) {
    sync();

    Rectangle rect = (a instanceof Rectangle) ? (Rectangle) a : a.getBounds();

    Image image = getImage();
    Rectangle clip = g.getClipBounds();

    fBounds.setBounds(rect);
    paintHighlights(g, a);
    paintBorder(g, rect);
    if (clip != null) {
      g.clipRect(
          rect.x + leftInset,
          rect.y + topInset,
          rect.width - leftInset - rightInset,
          rect.height - topInset - bottomInset);
    }
    if (image != null) {
      if (!hasPixels(image)) {
        // No pixels yet, use the default
        Icon icon = (image == null) ? getNoImageIcon() : getLoadingImageIcon();

        if (icon != null) {
          icon.paintIcon(getContainer(), g, rect.x + leftInset, rect.y + topInset);
        }
      } else {
        // Draw the image
        g.drawImage(image, rect.x + leftInset, rect.y + topInset, width, height, imageObserver);
      }
    } else {
      Icon icon = getNoImageIcon();

      if (icon != null) {
        icon.paintIcon(getContainer(), g, rect.x + leftInset, rect.y + topInset);
      }
      View view = getAltView();
      // Paint the view representing the alt text, if its non-null
      if (view != null && ((state & WIDTH_FLAG) == 0 || width > DEFAULT_WIDTH)) {
        // Assume layout along the y direction
        Rectangle altRect =
            new Rectangle(
                rect.x + leftInset + DEFAULT_WIDTH,
                rect.y + topInset,
                rect.width - leftInset - rightInset - DEFAULT_WIDTH,
                rect.height - topInset - bottomInset);

        view.paint(g, altRect);
      }
    }
    if (clip != null) {
      // Reset clip.
      g.setClip(clip.x, clip.y, clip.width, clip.height);
    }
  }
  protected int paintRecursive(
      Graphics g,
      int indentation,
      int descent,
      int childNumber,
      int depth,
      JTree tree,
      TreeModel mod,
      Object curr) {
    Rectangle clip = g.getClipBounds();
    if (indentation > clip.x + clip.width + rightChildIndent
        || descent > clip.y + clip.height + rowHeight) return descent;

    int halfHeight = rowHeight / 2;
    int halfWidth = rightChildIndent / 2;
    int y0 = descent + halfHeight;

    if (mod.isLeaf(curr)) {
      paintLeaf(g, indentation, descent, tree, curr);
      descent += rowHeight;
    } else {
      if (depth > 0 || tree.isRootVisible()) {
        paintNonLeaf(g, indentation, descent, tree, curr);
        descent += rowHeight;
        y0 += halfHeight;
      }
      int max = mod.getChildCount(curr);
      for (int i = 0; i < max; ++i) {
        g.setColor(hashColor);
        g.drawLine(
            indentation + halfWidth, descent + halfHeight,
            indentation + rightChildIndent, descent + halfHeight);
        descent =
            paintRecursive(
                g,
                indentation + rightChildIndent,
                descent,
                i,
                depth + 1,
                tree,
                mod,
                mod.getChild(curr, i));
      }
    }

    int y1 = descent - halfHeight;
    if (y0 != y1) {
      g.setColor(hashColor);
      g.drawLine(
          indentation + halfWidth, y0,
          indentation + halfWidth, y1);
    }

    return descent;
  }
Exemplo n.º 28
0
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Dimension sz = getSize();
    int top = Math.max(0, (sz.height - tableHeight) / 2);
    int left = Math.max(0, (sz.width - tableWidth) / 2);
    Model model = getModel();
    if (model == null) return;
    Selection sel = model.getSelection();
    int columns = sel.size();
    if (columns == 0) {
      g.setFont(BODY_FONT);
      GraphicsUtil.drawCenteredText(
          g, Strings.get("tableEmptyMessage"), sz.width / 2, sz.height / 2);
      return;
    }

    g.setColor(Color.GRAY);
    int lineY = top + cellHeight + HEADER_SEP / 2;
    g.drawLine(left, lineY, left + tableWidth, lineY);

    g.setColor(Color.BLACK);
    g.setFont(HEAD_FONT);
    FontMetrics headerMetric = g.getFontMetrics();
    int x = left;
    int y = top + headerMetric.getAscent() + 1;
    for (int i = 0; i < columns; i++) {
      x = paintHeader(sel.get(i).toShortString(), x, y, g, headerMetric);
    }

    g.setFont(BODY_FONT);
    FontMetrics bodyMetric = g.getFontMetrics();
    Rectangle clip = g.getClipBounds();
    int firstRow = Math.max(0, (clip.y - y) / cellHeight - 1);
    int lastRow = Math.min(rowCount, 2 + (clip.y + clip.height - y) / cellHeight);
    int y0 = top + cellHeight + HEADER_SEP;
    x = left;
    for (int col = 0; col < columns; col++) {
      SelectionItem item = sel.get(col);
      ValueLog log = model.getValueLog(item);
      int radix = item.getRadix();
      int offs = rowCount - log.size();
      y = y0 + Math.max(offs, firstRow) * cellHeight;
      for (int row = Math.max(offs, firstRow); row < lastRow; row++) {
        Value val = log.get(row - offs);
        String label = val.toDisplayString(radix);
        int width = bodyMetric.stringWidth(label);
        g.drawString(label, x + (cellWidth - width) / 2, y + bodyMetric.getAscent());
        y += cellHeight;
      }
      x += cellWidth + COLUMN_SEP;
    }
  }
Exemplo n.º 29
0
  protected void paintComponent(Graphics g) {
    if (isPaintMargin()) {
      Rectangle clip = g.getClipBounds();
      g.setColor(UIManager.getColor("control"));
      g.fillRect(clip.x, clip.y, clip.width, clip.height);

      if (m_gc != null) {
        java.awt.Graphics2D g2 = (java.awt.Graphics2D) g;
        g2.drawImage(m_column_thumb.getImage(), m_xpos - THUMB_WIDTH / 2, 0, this);
      }
    }
  }
Exemplo n.º 30
0
 @Override
 public void paint(final Graphics g) {
   // draw the image
   g.drawImage(m_current, 0, 0, this);
   final Rectangle rect = g.getClipBounds();
   if (rect.getWidth() > m_current.getWidth(this)
       || rect.getHeight() > m_current.getHeight(this)) {
     // we are being asked to draw on a canvas bigger than the image
     // clear the rest of the canvas
     // TODO deal with this.
   }
 }