Ejemplo n.º 1
0
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2d = (Graphics2D) g;
    g2d.setBackground(Color.LIGHT_GRAY);
    g2d.clearRect(0, 0, getParent().getWidth(), getParent().getHeight());

    // Red line
    g2d.setPaint(Color.RED);
    // 5 visible, 5 invisible
    final float dash[] = {5, 5};
    // 10 thick, end lines with no cap,
    // any joins make round, miter limit,
    // dash array, dash phase
    final BasicStroke dashed =
        new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0, dash, 0);

    g2d.setStroke(dashed);
    g2d.drawLine(100, 10, 10, 110);

    // White line
    g2d.setPaint(Color.WHITE);
    g2d.setStroke(new BasicStroke(10.0f));
    g2d.draw(new Line2D.Float(150, 10, 10, 160));

    // Blue line
    g2d.setPaint(Color.BLUE);
    Stroke solidStroke = new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    g2d.setStroke(solidStroke);
    g2d.draw(new Line2D.Float(new Point2D.Float(200, 10), new Point2D.Double(10, 210)));
  }
Ejemplo n.º 2
0
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    // Hole gesamte Tabelle
    Vector<Vector<Integer>> data = TableContainer.getInstance().getListItems();

    if (data != null) {
      // Umrandung
      g.setColor(Color.BLACK);
      g.drawRect(0, 0, this.xMaxScaled, this.yMaxScaled);

      g.setColor(Color.RED);

      for (int i = 1; i < data.size(); i++) {
        int x1, y1, x2, y2;

        try {
          x1 = data.get(i - 1).get(0) / Constants.GRAPH_SCALE_DIVISOR;
          y1 = data.get(i - 1).get(1) / Constants.GRAPH_SCALE_DIVISOR;
          x2 = data.get(i).get(0) / Constants.GRAPH_SCALE_DIVISOR;
          y2 = data.get(i).get(1) / Constants.GRAPH_SCALE_DIVISOR;
        } catch (Exception e) {
          System.out.println("Fehlerhafter Tabelleneintrag: " + e);
          return;
        }

        g.drawLine(x1, y1, x2, y2);
      }
    }
  }
Ejemplo n.º 3
0
 public void paintComponent(Graphics g)
 {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D)g;
   g2.setStroke(LineAttributes.getStrokes()[selectedIndex]);
   g2.drawLine(10, 10, 90, 10);
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 5
0
  public void paintComponent(Graphics g) {
    final Color bg = getBackground();
    final Insets insets = getInsets();

    if (shouldPaintBg) {
      super.paintComponent(g);

      if ((bg != null) && (bg.getAlpha() > 0)) {
        g.setColor(bg);
        g.fillRect(
            insets.left,
            insets.top,
            getWidth() - (insets.left + insets.right),
            getHeight() - (insets.top + insets.bottom));
      }
      if (!clear) {
        shouldPaintBg = false;
        setOpaque(true);
      }
    }
    if (pen != null) {
      if (pen.getAbsCoords()) {
        pen.paintIcon(this, g, 0, 0);
      } else {
        pen.paintIcon(this, g, insets.left, insets.top);
      }
    }
  }
Ejemplo n.º 6
0
 @Override
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   shape.draw(g2, new Point(getWidth() / 2, getHeight() / 2));
 }
Ejemplo n.º 7
0
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Dimension d = getSize();

    if (d.width != maxWidth || d.height != textHeight) recalculateDimension();

    Insets insets = this.getInsets();

    int y = 0;

    if (verticalAlignment == TOP) {
      y = insets.top + lineAscent;
    } else if (verticalAlignment == CENTER) {
      // These two are must musts:
      y = insets.top + lineAscent;

      // So far it looks like the TOP case, BUT:
      int clientAreaHeight = d.height - insets.top - insets.bottom;
      y = y + (clientAreaHeight - textHeight) / 2;
    } else if (verticalAlignment == BOTTOM) {
      int clientAreaBottom = d.height - insets.bottom;

      y = clientAreaBottom - textHeight;

      y += lineAscent;
    }

    for (int i = 0; i < numLines; i++) {
      int ha = getBidiHorizontalAlignment(horizontalAlignment);

      int x = 0;

      if (ha == LEFT) {
        ha = getBidiHorizontalAlignment(textAlignment);
        if (ha == LEFT) x = insets.left;
        else if (ha == RIGHT) x = maxWidth - lineWidths[i] + insets.left;
        else if (ha == CENTER) x = insets.left + (maxWidth - lineWidths[i]) / 2;
      } else if (ha == RIGHT) {
        ha = getBidiHorizontalAlignment(textAlignment);
        if (ha == LEFT) x = d.width - maxWidth - insets.right;
        else if (ha == RIGHT) x = d.width - lineWidths[i] - insets.right;
        else if (ha == CENTER)
          x = d.width - maxWidth - insets.right + (maxWidth - lineWidths[i]) / 2;
      } else if (ha == CENTER) {
        ha = getBidiHorizontalAlignment(textAlignment);

        // Just imagine that ha=LEFT (much easier), and follow code
        int clientAreaWidth = d.width - insets.left - insets.right;
        if (ha == LEFT) x = insets.left + (clientAreaWidth - maxWidth) / 2;
        else if (ha == RIGHT)
          x = insets.left + (clientAreaWidth - maxWidth) / 2 + (maxWidth - lineWidths[i]);
        else if (ha == CENTER) x = insets.left + (clientAreaWidth - lineWidths[i]) / 2;
      }
      x += btnMarginWidth;
      g.drawString(lines[i], x, y);

      y += lineHeight;
    }
  }
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (swithCache) {
     g.drawImage(imageBuffer1, 0, 0, null);
   } else {
     g.drawImage(imageBuffer2, 0, 0, null);
   }
 }
Ejemplo n.º 9
0
 @Override
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   Rectangle rec = g2.getClipBounds();
   long cap = rec.width * disk.getSize();
   g2.drawLine(rec.x, rec.y, (int) cap, rec.height);
 }
Ejemplo n.º 10
0
 @Override
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   g.translate(getWidth() / 2, getHeight() / 2);
   int x = (int) (r * Math.cos(Math.toRadians(szog)));
   int y = (int) (r * Math.sin(Math.toRadians(szog)));
   g.drawLine(-x, -y, x, y);
 }
Ejemplo n.º 11
0
  @Override
  public void paintComponent(final Graphics g) {
    super.paintComponent(g);

    // draw entire component white
    g.setColor(Color.white);
    g.fillRect(0, 0, getWidth(), getHeight());

    // yellow circle
    g.setColor(Color.yellow);
    g.fillOval(0, 0, 240, 240);

    // magenta circle
    g.setColor(Color.magenta);
    g.fillOval(160, 160, 240, 240);

    // paint the icon below blue sqaure
    int w = java2sLogo.getIconWidth();
    int h = java2sLogo.getIconHeight();
    java2sLogo.paintIcon(this, g, 280 - (w / 2), 120 - (h / 2));

    // paint the icon below red sqaure
    java2sLogo.paintIcon(this, g, 120 - (w / 2), 280 - (h / 2));

    // transparent red square
    g.setColor(m_tRed);
    g.fillRect(60, 220, 120, 120);

    // transparent green circle
    g.setColor(m_tGreen);
    g.fillOval(140, 140, 120, 120);

    // transparent blue square
    g.setColor(m_tBlue);
    g.fillRect(220, 60, 120, 120);

    g.setColor(Color.black);

    g.setFont(monoFont);
    FontMetrics fm = g.getFontMetrics();
    w = fm.stringWidth("Java Source");
    h = fm.getAscent();
    g.drawString("Java Source", 120 - (w / 2), 120 + (h / 4));

    g.setFont(sanSerifFont);
    fm = g.getFontMetrics();
    w = fm.stringWidth("and");
    h = fm.getAscent();
    g.drawString("and", 200 - (w / 2), 200 + (h / 4));

    g.setFont(serifFont);
    fm = g.getFontMetrics();
    w = fm.stringWidth("Support.");
    h = fm.getAscent();
    g.drawString("Support.", 280 - (w / 2), 280 + (h / 4));
  }
Ejemplo n.º 12
0
 @Override
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   double x = Board.L * model.getX();
   double y = Board.L * model.getY();
   double w = Board.L * model.getWidth();
   double h = Board.L * model.getHeight();
   g.setColor(model.getColor());
   g.fillRect((int) Math.round(x), (int) Math.round(y), (int) Math.round(w), (int) Math.round(h));
 }
Ejemplo n.º 13
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2d = (Graphics2D) g;
   g2d.setBackground(Color.white);
   g2d.clearRect(0, 0, Data.screenWidth, Data.screenHeight);
   synchronized (RenderableHolder.getInstance()) {
     for (IRenderable entity : RenderableHolder.getInstance().getRenderableList()) {
       if (entity.isVisible()) entity.render(g2d);
     }
   }
 }
Ejemplo n.º 14
0
  /** Paint this component, including its image. */
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    g.drawImage(
        this.image.getImage(),
        0,
        0,
        this.image.getImage().getWidth(null),
        this.image.getImage().getHeight(null),
        null);
  }
Ejemplo n.º 15
0
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

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

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(color);
    g2.fillOval(0, 0, getWidth(), getHeight());
    g2.dispose();
  }
Ejemplo n.º 16
0
  protected void paintComponent(Graphics g) {
    setBackground(Color.BLACK);
    super.paintComponent(g);

    for (int x = 0; x < lifegrid.getWidth(); x++) {
      for (int y = 0; y < lifegrid.getHeight(); y++) {
        if (lifegrid.instant[y][x] == 1) {
          g.setColor(Color.GREEN);
          g.fillRect(x * squareSize, y * squareSize, squareSize, squareSize);
        }
      }
    }
  }
Ejemplo n.º 17
0
 /** [Internal] */
 public void paintComponent(Graphics g) {
   boolean opq = true;
   if (theOpaque != null) opq = theOpaque;
   super.setOpaque(opq);
   // if(theBackground!=null)super.setBackground(theBackground);
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   Rectangle rt = getBounds();
   rt.x = 0;
   rt.y = 0;
   doBuffer(g2, opq, rt);
   chkFPS();
 }
Ejemplo n.º 18
0
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(new Color(RGBBGColor[0], RGBBGColor[1], RGBBGColor[2]));
    g.fillRect(0, 0, getWidth(), getHeight());

    g.setColor(new Color(RGBColor[0], RGBColor[1], RGBColor[2]));
    g.fillRect(
        borderWidth, borderWidth, getWidth() - 2 * borderWidth, getHeight() - 2 * borderWidth);

    g.setColor(Color.BLACK);
    g.drawString(event.getDescription(), 2, 10);
  }
Ejemplo n.º 19
0
  @Override
  protected void paintComponent(Graphics g) {
    // TODO Auto-generated method stub
    super.paintComponent(g);
    // g.drawLine(0, 300, 600, 50);
    g.setColor(Color.YELLOW);
    g.fillOval(x, 50, 500, 500);
    g.setColor(Color.WHITE);
    g.fillOval(150, 100, 100, 100);
    g.fillOval(350, 100, 100, 100);
    g.setColor(Color.BLUE);
    // g.fillOval(180, y, 50, 50);
    // g.fillOval(380, 100, 50, 50);
    g.setColor(Color.RED);
    g.fillArc(x3, 350, 350, 150, 180, 180);
    g.setColor(Color.MAGENTA);
    g.fillArc(x2, 350, 100, 200, 200, -200);
    g.setColor(Color.BLACK);

    g.setColor(Color.BLUE);
    g.fillOval(180, y, 50, h);
    g.fillOval(380, y, 50, h);
    y++;
    if (y == 150) {
      y = 100;
    }
    x--;
    if (x == 50) {
      x = 100;
    }
    x2--;
    if (x2 == 200) {
      x2 = 250;
    }
    h++;
    if (h == 50) {
      h = 0;
    }
    x3--;
    if (x3 == 100) {
      x3 = 150;
    }

    try {
      Thread.sleep(20);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    super.repaint();
  }
Ejemplo n.º 20
0
  /**
   * GlyphGutter copy pasted bolerplate method. It invokes {@link #paintView} that contains actual
   * business logic.
   */
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Rectangle clip = g.getClipBounds();

    JTextComponent component = editorUI.getComponent();
    if (component == null) return;

    BaseTextUI textUI = (BaseTextUI) component.getUI();
    View rootView = Utilities.getDocumentView(component);
    if (rootView == null) return;

    g.setColor(backgroundColor());
    g.fillRect(clip.x, clip.y, clip.width, clip.height);

    AbstractDocument doc = (AbstractDocument) component.getDocument();
    doc.readLock();
    try {
      foldHierarchy.lock();
      try {
        int startPos = textUI.getPosFromY(clip.y);
        int startViewIndex = rootView.getViewIndex(startPos, Position.Bias.Forward);
        int rootViewCount = rootView.getViewCount();

        if (startViewIndex >= 0 && startViewIndex < rootViewCount) {
          int clipEndY = clip.y + clip.height;
          for (int i = startViewIndex; i < rootViewCount; i++) {
            View view = rootView.getView(i);
            Rectangle rec = component.modelToView(view.getStartOffset());
            if (rec == null) {
              break;
            }
            int y = rec.y;
            paintView(view, g, y);
            if (y >= clipEndY) {
              break;
            }
          }
        }

      } finally {
        foldHierarchy.unlock();
      }
    } catch (BadLocationException ble) {
      Mercurial.LOG.log(Level.WARNING, null, ble);
    } finally {
      doc.readUnlock();
    }
  }
    public void paintComponent(Graphics g) {
      super.paintComponent(g);

      Graphics2D g2 = (Graphics2D) g;

      if (!text.equals("")) {
        g2.translate(0, getSize().getHeight());
        g2.rotate(-Math.PI / 2);
        g2.setColor(Color.black);
        g2.drawString(text, 20, 14);

        g2.translate(0, -getSize().getHeight());
        g2.transform(AffineTransform.getQuadrantRotateInstance(1));
      }
    }
Ejemplo n.º 22
0
  /** Draws the game */
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    final Graphics2D g2 = (Graphics2D) g;

    /** Draw all the non-falling blocks on the board. Non-OUTSIDE blocks have rounded corners. */
    for (int row = 0; row < board.getHeight(); row++) {
      for (int column = 0; column < board.getWidth(); column++) {
        if (board.getSquareType(row, column) != SquareType.OUTSIDE) {
          Shape tetrominoBlock =
              new RoundRectangle2D.Double(
                  column * SQUARE_WIDTH, row * SQUARE_HEIGHT, SQUARE_WIDTH, SQUARE_HEIGHT, 5, 5);
          g2.setColor(SQUARE_COLOR.get(board.getSquareType(row, column)));
          g2.fill(tetrominoBlock);
          g2.draw(tetrominoBlock);
        } else {
          Shape tetrominoBlock =
              new Rectangle2D.Double(
                  column * SQUARE_WIDTH, row * SQUARE_HEIGHT, SQUARE_WIDTH, SQUARE_HEIGHT);
          g2.setColor(SQUARE_COLOR.get(board.getSquareType(row, column)));
          g2.fill(tetrominoBlock);
          g2.draw(tetrominoBlock);
        }
      }
    }

    Poly tempPoly = board.getFalling();
    if (tempPoly != null) {

      for (int row = 0; row < tempPoly.getSize(); row++) {
        for (int column = 0; column < tempPoly.getSize(); column++) {
          if (tempPoly.getSquareType(row, column) != SquareType.EMPTY) {
            Shape tetrominoBlock =
                new RoundRectangle2D.Double(
                    (column + board.getFallingPosX()) * SQUARE_WIDTH,
                    (row + board.getFallingPosY()) * SQUARE_HEIGHT,
                    SQUARE_WIDTH,
                    SQUARE_HEIGHT,
                    5,
                    5);
            g2.setColor(SQUARE_COLOR.get(tempPoly.getSquareType(row, column)));
            g2.fill(tetrominoBlock);
            g2.draw(tetrominoBlock);
          }
        }
      }
    }
  }
Ejemplo n.º 23
0
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2 = (Graphics2D) g;
    Ellipse2D.Double cell = new Ellipse2D.Double(0, 0, DOT_SIZE, DOT_SIZE);
    for (int r = 0; r < MAX_ROWS; r++) {
      for (int c = 0; c < MAX_COLUMNS; c++) {
        if (isOccupied(r, c)) {
          cell.y = DOT_SIZE * r;
          cell.x = DOT_SIZE * c;
          g2.fill(cell);
        }
      }
    }
  }
Ejemplo n.º 24
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    ((Graphics2D) g).setBackground(Color.BLACK);
    for (Renderable e : RenderableHolder.getInstance().getRenderableList()) {
      if (e.isVisible() && e.getZ() < -1) e.draw((Graphics2D) g);
    }
    for (Monster m : Cage.getInstance().getCage()) {
      if (m.isVisible()) {
        m.draw((Graphics2D) g);
      }
    }
    for (Renderable e : RenderableHolder.getInstance().getRenderableList()) {
      if (e.isVisible() && e.getZ() >= -1) e.draw((Graphics2D) g);
    }
  }
Ejemplo n.º 25
0
 @Override
 protected void paintComponent(final Graphics g) {
   super.paintComponent(g);
   int y = 0;
   for (int i = 0; i < competitorGroups.size(); i++) {
     final CompetitorGroup group = competitorGroups.get(i);
     final int listHeight = getListHeight(i);
     final float min = group.getMinGroupWeight();
     final float max = group.getMaxGroupWeight();
     final int purcent = group.getWeightStepInPercent();
     g.drawString(
         String.valueOf(min) + " à  " + String.valueOf(max) + " kg (" + purcent + "%)",
         0,
         y + listHeight / 2);
     y += listHeight;
   }
 }
Ejemplo n.º 26
0
  @Override
  protected void paintComponent(Graphics g1d) {
    super.paintComponent(g1d);
    Graphics2D g = (Graphics2D) g1d;

    // Hintergrund weiß zeichnen
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, getWidth(), getHeight());

    // SceneRenderer den Rest machen lassen
    synchronized (origin) {
      zoom =
          (Math.min(getWidth(), getHeight()) - 2 * defborder)
              / (2 * renderer.getData().getRadius());
      origin = renderer.render(g, move, getWidth(), getHeight(), zoom);
    }
  }
Ejemplo n.º 27
0
 @Override
 protected void paintComponent(Graphics graphics) {
   super.paintComponent(graphics);
   if (active) {
     graphics.setColor(new Color(199, 199, 199));
     graphics.fillRect(0, 0, getWidth(), getHeight());
     graphics.setColor(new Color(116, 116, 116));
     graphics.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
   }
   graphics.drawImage(
       image,
       paddingSize,
       paddingSize,
       getWidth() - 2 * paddingSize,
       getHeight() - 2 * paddingSize,
       this);
 }
Ejemplo n.º 28
0
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (!(g instanceof Graphics2D)) return;

    Graphics2D g2 = (Graphics2D) g;

    AffineTransform at = fromImageToOuterTransform();
    g2.drawRenderedImage(mapImage, at);

    drawPlayerTokens(g2);

    if (highlightedArea != null) {
      drawHighlightedArea(highlightedArea, g2);
    }

    drawPlayerInfo(g2);
  }
Ejemplo n.º 29
0
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    int centerX = this.getWidth() / 2;
    int centerY = this.getHeight() / 2;
    int radius = Math.min(getWidth() - 4, getHeight() - 4) / 2;
    double angle = myController.getValue() * 2 * Math.PI;

    g.fillOval(centerX - radius, centerY - radius, radius * 2, radius * 2);
    g.setColor(Color.yellow);
    g.fillArc(
        centerX - radius, centerY - radius, radius * 2, radius * 2, 0, (int) Math.toDegrees(angle));

    int pinX = centerX + (int) (Math.cos(angle) * radius);
    int pinY = centerY - (int) (Math.sin(angle) * radius);
    g.setColor(Color.gray.brighter());
    g.fill3DRect(pinX - 4, pinY - 4, 8, 8, true);
  }
Ejemplo n.º 30
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   Graphics2D g2 = (Graphics2D) g;
   FontRenderContext frc = new FontRenderContext(null, true, true);
   Font f = helvFont.deriveFont(Font.PLAIN, 40);
   System.out.println("font = " + f.getFontName());
   GlyphVector gv = f.createGlyphVector(frc, codes);
   g.setFont(f);
   g.setColor(Color.white);
   g.fillRect(0, 0, 400, 400);
   g.setColor(Color.black);
   g2.drawGlyphVector(gv, 5, 200);
   g2.setRenderingHint(
       RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
   g2.setRenderingHint(
       RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
   g2.drawString(str, 5, 250);
 }