コード例 #1
1
ファイル: Map.java プロジェクト: Kuvik/CoopEvo
  public void paint(Graphics g) {
    // paint()
    int x, y;
    Random place = new Random(WorldParams.version);
    g.translate(5, 25);
    Color curColor = new Color(0, 0, 0);

    if (pleaseDraw) {
      for (int i = 0; i < WorldParams.worldXsize; i++)
        for (int j = 0; j < WorldParams.worldYsize; j++) {
          curColor = new Color(0, 0, 0);
          if (World2D.cWorld[i][j].hereIsGrass) curColor = new Color(0, 100, 0);
          g.setColor(curColor);
          g.fillRect(i * scale, j * scale, scale, scale);
          if (World2D.cWorld[i][j].agents.size() > 0) {
            for (int z = 0; z < World2D.cWorld[i][j].agents.size(); z++) {
              x = place.nextInt(scale - 8);
              y = place.nextInt(scale - 8);
              agent = (Genome) World2D.cWorld[i][j].agents.elementAt(z);
              switch (agent.act) {
                case 0: // rest
                  curColor = new Color(255, 255, 255);
                  break;
                case 1: // eat
                  curColor = new Color(255, 255, 0);
                  break;
                case 2: // moving
                  curColor = new Color(100, 100, 250);
                  break;
                case 3: // turn left
                  curColor = new Color(0, 0, 255);
                  break;
                case 4: // turn right
                  curColor = new Color(0, 0, 255);
                  break;
                case 5: // divide
                  curColor = new Color(255, 50, 150);
                  break;
                case 6: // fight
                  curColor = new Color(255, 0, 0);
                  break;
              } // end switch
              g.setColor(curColor);
              g.fillRect(i * scale + x, j * scale + y, 8, 8);
            }
          }
        }
    }
    pleaseDraw = false;
    if (fForm_Create) InitialPositionSet();
  } // End of paint()
コード例 #2
0
ファイル: Card.java プロジェクト: agale123/Catan
  public void paint(Graphics g) {

    g.fillRect((_x), (_y), _w, _h);
    g.fillRect((_x), (_y), _w, _h);
    g.fillRect((_x), (_y), _w, _h);
    g.drawImage(images.get(mytype), (_x), (_y), _w, _h, null);
  }
コード例 #3
0
ファイル: Loop.java プロジェクト: losalamos/coNCePTuaL
  public void paintComponent(Graphics graphics) {
    Rectangle bounds = getBounds();
    GraphicsUtility graphicsUtility = new GraphicsUtility(graphics);
    graphicsUtility.setStroke(GraphicsUtility.STROKE_BOLD);

    if (isSelected()) {
      graphics.setColor(GraphicsUtility.getSelectedColor());
      graphics.fillRect(0, 0, bounds.width, SELECT_BORDER_SIZE);
      graphics.fillRect(0, 0, SELECT_BORDER_SIZE, bounds.height);
      graphics.fillRect(0, bounds.height - SELECT_BORDER_SIZE, bounds.width, SELECT_BORDER_SIZE);
      graphics.fillRect(bounds.width - SELECT_BORDER_SIZE, 0, SELECT_BORDER_SIZE, bounds.height);
      graphics.setColor(Color.BLACK);
    }
    graphics.drawString(getCaption(), 10, 10);

    graphicsUtility.drawArrow(
        8, BORDER_INSET, BORDER_INSET, BORDER_INSET, bounds.height - BORDER_INSET);
    graphicsUtility.drawArrow(
        8,
        BORDER_INSET,
        bounds.height - BORDER_INSET,
        bounds.width - BORDER_INSET,
        bounds.height - BORDER_INSET);
    graphicsUtility.drawArrow(
        8,
        bounds.width - BORDER_INSET,
        bounds.height - BORDER_INSET,
        bounds.width - BORDER_INSET,
        BORDER_INSET);
    graphicsUtility.drawArrow(
        8, bounds.width - BORDER_INSET, BORDER_INSET, bounds.width - 50, BORDER_INSET);
    graphicsUtility.setStroke(GraphicsUtility.STROKE_NORMAL);
  }
コード例 #4
0
ファイル: hockey.java プロジェクト: alakshmi1030/Pong-v.-1.0
  public void paint(Graphics g) {
    g.setColor(Color.red);
    g.fillRect(xpos1, ypos1, width, length);

    g.setColor(Color.blue);
    g.fillRect(xpos2, ypos2, width, length);

    g.setColor(Color.green);
    g.fillOval(x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);

    Font text = new Font("Arial", Font.BOLD, 16);
    setFont(text);
    g.setColor(Color.white);
    g.drawString("Pong v. 1.0", 200, 25);

    message1 = "Player 1 Score: " + score1;
    message2 = "Player 2 Score: " + score2;

    g.drawString(message1, 10, 30);
    g.drawString(message2, 325, 30);

    if ((score1 == 10) || (score2 == 10)) {
      g.drawString(gameover, 175, 250);
    }
  }
コード例 #5
0
ファイル: VisualBellViewport.java プロジェクト: zieglerm/enh
 private void paintBell(Graphics g) {
   P9TermPreferences preferences = P9Term.getPreferences();
   if (preferences.getBoolean(P9TermPreferences.VISUAL_BELL) == false) {
     return;
   }
   Color foreground = preferences.getColor(P9TermPreferences.FOREGROUND_COLOR);
   if (preferences.getBoolean(P9TermPreferences.FANCY_BELL)) {
     // On decent hardware, we can produce a really tasteful effect by compositing a
     // semi-transparent rectangle over the terminal.
     // We need to choose a color that will show up against the background.
     // A reasonable assumption is that the user has already chosen such a color for the
     // foreground.
     Color color =
         new Color(foreground.getRed(), foreground.getGreen(), foreground.getBlue(), 100);
     g.setColor(color);
     g.fillRect(0, 0, getWidth(), getHeight());
   } else {
     // On a remote X11 display (or really rubbish hardware) the compositing effect is
     // prohibitively expensive, so we offer XOR instead.
     Color background = preferences.getColor(P9TermPreferences.BACKGROUND_COLOR);
     ;
     final int R = blend(background.getRed(), foreground.getRed());
     final int G = blend(background.getGreen(), foreground.getGreen());
     final int B = blend(background.getBlue(), foreground.getBlue());
     g.setColor(background);
     g.setXORMode(new Color(R, G, B));
     g.fillRect(0, 0, getWidth(), getHeight());
     g.setPaintMode();
   }
 }
コード例 #6
0
  // draws the button, based on the type of button (ImageIcon, Image, or String)
  public void draw(Graphics g) {
    if (visible) {
      // if its image/imageicon, draw it
      g.setColor(new Color(50, 200, 50));
      g.fillRect(x - 1, y - 1, width + 2, height + 2);
      if (mode.equals("Image") || mode.equals("ImageIcon")) {
        if (enabled) {
          g.drawImage(image, x, y, null);
        } else {
          g.drawImage(BWimage, x, y, null);
        }
        // if its string, draw the string
      } else {

        g.setFont(new Font("Arial", Font.PLAIN, 20));
        if (enabled) {
          g.setColor(Color.black);
          g.drawString(message, x + 20, y + 20);
        } else {
          g.setColor(new Color(255, 255, 255));
          g.fillRect(x - 1, y - 1, width + 2, height + 2);
          g.setColor(Color.black);
          g.drawString(message, x + 20, y + 20);
        }
      }
    }
  }
コード例 #7
0
  public void paint(Graphics g) {
    g.setFont(getFont());

    Color boxColor = getBackgroundBoxColor();
    Color hatchColor = getHatchColor();
    Color backgroundLineColor = getBackgroundLineColor();
    //    Color textColor = getForeground();
    int outlineType = getOutlineType();
    Color outlineColor = getOutlineColor();

    if (backgroundLineColor != null) {
      g.setColor(backgroundLineColor);
      g.fillRect(0, getSize().height / 2 - 1, getSize().width, 2);
    }

    if (boxColor != null) {
      g.setColor(boxColor);
      g.fillRect(0, 0, getSize().width, getSize().height);
    }

    if (hatchColor != null) {
      g.setColor(hatchColor);

      // Bev thinks the cross-hatching makes it too hard to read the base.
      // For a single diagonal line, replace the following three lines with
      // g.drawLine(0,getSize().height, getSize().width,0);
      // For an underline, replace with
      // g.drawLine(0,getSize().height, getSize().width,getSize().height);

      // Draw three cross-hatch lines
      // g.drawLine(0,0,getSize().width,getSize().height);
      // g.drawLine(getSize().width/2,0,getSize().width,getSize().height/2);
      // g.drawLine(0,getSize().height/2,getSize().width/2,getSize().height);

      // Draw a line at top and bottom of matching base
      g.drawLine(0, getSize().height, getSize().width, getSize().height); // bottom
      g.drawLine(0, 0, getSize().width, 0); // top
      //      g.drawLine(0,0, 0,getSize().height);  // left side
      //      g.drawLine(getSize().width,0, getSize().width,getSize().height);  // right side
    }

    if (outlineType != NO_OUTLINE && outlineColor != null) {
      g.setColor(outlineColor);
      g.drawLine(0, 0, getSize().width - 1, 0);
      g.drawLine(0, getSize().height - 1, getSize().width - 1, getSize().height - 1);
      if (outlineType == LEFT_OUTLINE) g.drawLine(0, 0, 0, getSize().height - 1);
      else if (outlineType == RIGHT_OUTLINE) {
        g.drawLine(getSize().width - 1, 0, getSize().width - 1, getSize().height - 1);
      }
    }

    if (getTextColor() != null) {
      int leadDistance = (getSize().width - metrics.charWidth(c)) / 2;
      g.setColor(getTextColor());
      g.drawString(c + "", leadDistance, getSize().height - 2);
    }
  }
コード例 #8
0
ファイル: Map.java プロジェクト: ZachLiss/Traveling-Salesman
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(BACKGROUND);
    g.fillRect(0, 0, width, height);
    g.setColor(FOREGROUND);

    for (int i = 0; i < NUMBOXES; i++) {
      g.fillRect(boxXs[i], boxYs[i], BOXWIDTH, BOXHEIGHT);
      g.drawLine(lineXs[i], lineYs[i], lineXXs[i], lineYYs[i]);
    }
  }
コード例 #9
0
  void displayScrollBar(Graphics g) {
    int x = getCursorX();
    int y = getCursorY();
    g.setColor(0xffffff);
    g.fillRect(getWidth() - 5, 0, 5, getHeight());
    g.setColor(0x000000);
    g.drawLine(getWidth() - 5, 0, getWidth() - 5, getHeight());

    int hScrollMin = inputHeight;

    int yScroll = (((linesOnScreen - 1) * y) * inputHeight) / getLinesCount();

    g.fillRect(getWidth() - 5, yScroll, 5, hScrollMin);
  }
コード例 #10
0
 public static DrawingPanel background(String meaning) {
   DrawingPanel panel = new DrawingPanel(780, 560);
   Graphics g = panel.getGraphics();
   panel.setBackground(Color.white);
   g.setColor(Color.LIGHT_GRAY);
   g.fillRect(0, 0, 781, bannerHeight);
   g.fillRect(0, 530, 781, bannerHeight);
   g.setColor(Color.black);
   g.drawString(meaning, 0, 16);
   for (int i = startYear; i <= 2010; i += 10) {
     g.drawString("" + i, (decadeWidth / 10) * (i - startYear), 552);
   }
   return panel;
 }
コード例 #11
0
  void drawboard(Graphics g) {
    g.setColor(Color.black);
    g.fillRect(0, 0, getWidth(), getHeight());

    sqw = getWidth() / xdim;
    sqh = getHeight() / ydim;

    // draw background panels
    if (def != null) {
      for (int y = 0; y < ydim; y++) {
        for (int x = 0; x < xdim; x++) def.drawObject(g, x, y, sqw, sqh, this);
      }
    }

    if (USEVEC) {
      // draw each element in the vector
      for (Enumeration e = boardVec.elements(); e.hasMoreElements(); ) {
        boardContainer c = (boardContainer) e.nextElement();
        c.o.drawObject(g, c.d.width, c.d.height, sqw, sqh, this);
      }
    } else {
      // draw from grid
      for (int y = 0; y < ydim; y++) {
        for (int x = 0; x < xdim; x++)
          if (board[x][y] != null) board[x][y].drawObject(g, x, y, sqw, sqh, this);
      }
    }
  }
コード例 #12
0
  void displayCharacterMap(Graphics g) {
    if (currentChars != null) {
      g.setColor(0xffffff);
      g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
      g.setColor(0x000000);
      g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
      for (int i = 0; i < currentChars.length; i++) {
        char ch = currentChars[i];
        if (isUppercase) {
          ch = String.valueOf(currentChars[i]).toUpperCase().charAt(0);
        }

        // TODO: if i*12 > getWidth() ?

        g.drawChar(ch, i * 12, getHeight() - inputHeight, Graphics.LEFT | Graphics.TOP);
        if (currentChars[currentKeyStep] == currentChars[i]) {
          g.drawRect(
              i * 12 - 2,
              getHeight() - inputHeight - 2,
              inputFont.charWidth(ch) + 4,
              inputHeight + 4);
        }
      }
    }
  }
コード例 #13
0
ファイル: Grid.java プロジェクト: jankotek/asterope
  /** Affichage du logo */
  protected void drawLogo(Graphics g) {

    int x = 5;
    int y = 2;

    g.setColor(getBackground());
    g.fillRect(0, 0, W, H);

    // Remplissage
    fillBG(g, x, y, Color.white);

    // Dessin
    drawGrid(
        g,
        x,
        y,
        !isAvailable()
            ? Aladin.MYGRAY
            : isActive() ? Aladin.GREEN : isMouseIn() ? Color.blue : Color.black);

    // Label
    g.setColor(isAvailable() ? Color.black : Aladin.MYGRAY);
    g.setFont(Aladin.SPLAIN);
    g.drawString(LABEL, W / 2 - g.getFontMetrics().stringWidth(LABEL) / 2, H - 2);
  }
コード例 #14
0
ファイル: ShowSavedResults.java プロジェクト: pjotrp/EMBOSS
  public void paint(Graphics g) {
    m_fm = g.getFontMetrics();

    g.setColor(getBackground());
    g.fillRect(0, 0, getWidth(), getHeight());
    getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());

    g.setColor(getForeground());
    g.setFont(getFont());
    m_insets = getInsets();
    int x = m_insets.left;
    int y = m_insets.top + m_fm.getAscent();

    StringTokenizer st = new StringTokenizer(getText(), "\t");
    while (st.hasMoreTokens()) {
      String sNext = st.nextToken();
      g.drawString(sNext, x, y);
      x += m_fm.stringWidth(sNext);

      if (!st.hasMoreTokens()) break;
      int index = 0;
      while (x >= getTab(index)) index++;
      x = getTab(index);
    }
  }
コード例 #15
0
  // ------------------------------------------------------------------------
  // SCREEN PAINTER
  // Put some function here to paint whatever you want over the screen before and after
  // all edges and nodes have been painted.
  public void PaintScreenBefore(Graphics g) {

    Dimension d = MainClass.mainFrame.GetGraphDisplayPanel().getSize();
    NodeInfo nodeInfo;
    int x = 0;
    int y = 0;
    int step = 10;

    for (; x < d.width; x += step) {
      for (y = 0; y < d.height; y += step) {
        double val = 0;
        double sum = 0;
        double total = 0;
        double min = 10000000;
        for (Enumeration nodes = proprietaryNodeInfo.elements(); nodes.hasMoreElements(); ) {
          nodeInfo = (NodeInfo) nodes.nextElement();
          double dist = distance(x, y, nodeInfo.centerX, nodeInfo.centerY);
          if (nodeInfo.value != -1 && nodeInfo.nodeNumber.intValue() != 1) { // 121
            if (dist < min) min = dist;
            val += ((double) nodeInfo.value) / dist / dist;
            sum += (1 / dist / dist);
          }
        }
        int reading = (int) (val / sum);
        reading = reading >> 2;
        if (reading > 255) reading = 255;
        g.setColor(new Color(reading, reading, reading));
        g.fillRect(x, y, step, step);
      }
    }
  }
コード例 #16
0
  public void draw(Graphics g) {
    animate();

    g.setColor(Color.black);
    g.fillRect(0, 0, dim.width, dim.height);
    g.setColor(Color.white);

    numpaint++;
    DebugPrinter dbg = new DebugPrinter(g, 50, 60);
    dbg.print(
        "Spring-mass demo by yigal irani, drag balls or create new ones by clicking inside box");
    dbg.print("frame", numpaint);
    dbg.print("fps", 1 / timer.time_diff);

    Point top_left = point_by_vec(new Vec(-1, 1));
    g.draw3DRect(top_left.x, top_left.y, screen_dist(2), screen_dist(2), true);
    for (int i = 0; i < springs.size(); i++) {
      Spring spring = springs.get2(i);
      Point p1 = point_by_vec(balls.get2(spring.start).pos);
      Point p2 = point_by_vec(balls.get2(spring.end).pos);
      g.drawLine(p1.x, p1.y, p2.x, p2.y);
    }
    for (int i = 0; i < balls.size(); i++) {
      Ball ball = balls.get2(i);
      Point p = point_by_vec(ball.pos);
      int screen_radius = screen_dist(RADIUS);
      g.setColor(Color.blue);
      g.fillOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.setColor(Color.white);
      g.drawOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.drawString("" + i, p.x, p.y);
    }
  }
コード例 #17
0
 public void paint(Graphics g) {
   g.drawRect(x[0], y[0], 40, 40);
   g.fillRect(x[1], y[1], 20, 20);
   g.drawLine(x[2], y[2], x[3], y[3]);
   g.drawOval(x[4], y[4], 20, 30);
   g.drawString("Moveing", x[5], y[5]);
 }
コード例 #18
0
ファイル: View.java プロジェクト: kaschenko/lab3
    private void drawSquare(Graphics g, int x, int y, Tetrominoes shape) {

      int squareWidth = (int) getSize().getWidth() / model.getWidth();
      int squareHeight = (int) getSize().getHeight() / model.getHeight();

      Color colors[] = {
        new Color(0, 0, 0),
        new Color(204, 102, 102),
        new Color(102, 204, 102),
        new Color(102, 102, 204),
        new Color(204, 204, 102),
        new Color(204, 102, 204),
        new Color(102, 204, 204),
        new Color(218, 170, 0)
      };

      Color color = colors[shape.ordinal()];
      g.setColor(color);
      g.fillRect(x + 1, y + 1, squareWidth - 2, squareHeight - 2);
      g.setColor(color.brighter());
      g.drawLine(x, y + squareHeight - 1, x, y);
      g.drawLine(x, y, x + squareWidth - 1, y);

      g.setColor(color.darker());
      g.drawLine(x + 1, y + squareHeight - 1, x + squareWidth - 1, y + squareHeight - 1);
      g.drawLine(x + squareWidth - 1, y + squareHeight - 1, x + squareWidth - 1, y + 1);
    }
コード例 #19
0
  public void paint(Graphics gg) {
    int faceSize = Math.min(getWidth() - 4, getHeight() - 4);
    if (face == null)
      face =
          new PADFaceMapped(
              Math.max(2, (getWidth() - faceSize) / 2),
              Math.max(2, (getHeight() - faceSize) / 2),
              faceSize);
    if (buffer == null) {
      im = this.createImage(getWidth(), getHeight());
      buffer = im.getGraphics();
    }
    super.paint(buffer);

    buffer.setColor(new Color(255, 255, 255, 0));
    buffer.fillRect(0, 0, im.getWidth(null), im.getHeight(null));

    face.setDimensions(
        Math.max(2, (getWidth() - faceSize) / 2),
        Math.max(2, (getHeight() - faceSize) / 2),
        faceSize);
    face.paint(buffer);

    // draw buffer to screen
    gg.drawImage(im, 0, 0, null, null);
  }
コード例 #20
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (uneHashtable.get(unEtat) != null) {
     g.setColor((Color) uneHashtable.get(unEtat));
     g.fillRect(100, 20, 40, 40);
   }
 }
コード例 #21
0
 void displayStatus(Graphics g) {
   if (statusString != null) {
     g.setColor(0xffffff);
     g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
     g.setColor(0x000000);
     g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
     g.drawString(statusString, 0, getHeight() - inputHeight - 2, Graphics.LEFT | Graphics.TOP);
   }
 }
コード例 #22
0
ファイル: set.java プロジェクト: wcyuan/Set
    public void draw(Graphics g, ImageObserver ob) {
      if (!todraw) {
        g.setColor(bgcolor);
        g.drawRect(x, y, w + 2 * border, h + 2 * border);
        g.fillRect(x, y, w + 2 * border, h + 2 * border);
        return;
      }

      if (selected) g.setColor(selected_color);
      else g.setColor(unselected_color);

      g.drawRect(x, y, w + 2 * border, h + 2 * border);
      g.fillRect(x, y, w + 2 * border, h + 2 * border);
      g.drawImage(image[im], x + border, y + border, ob);

      // g.setColor(Color.black);
      // g.drawString("" + im,x+5,y+5);
    }
コード例 #23
0
ファイル: JREImage.java プロジェクト: kazuyakuza/wh40kh
 /**
  * Turn a (possibly) translucent or indexed image into a display-compatible bitmask image using
  * the given alpha threshold and render-to-background colour, or display-compatible translucent
  * image. The alpha values in the image are set to either 0 (below threshold) or 255 (above
  * threshold). The render-to-background colour bg_col is used to determine how the pixels
  * overlapping transparent pixels should be rendered. The fast algorithm just sets the colour
  * behind the transparent pixels in the image (for bitmask source images); the slow algorithm
  * actually renders the image to a background of bg_col (for translucent sources).
  *
  * @param thresh alpha threshold between 0 and 255
  * @param fast use fast algorithm (only set bg_col behind transp. pixels)
  * @param bitmask true=use bitmask, false=use translucent
  */
 public JGImage toDisplayCompatible(int thresh, JGColor bg_col, boolean fast, boolean bitmask) {
   Color bgcol = new Color(bg_col.r, bg_col.g, bg_col.b);
   int bgcol_rgb = (bgcol.getRed() << 16) | (bgcol.getGreen() << 8) | bgcol.getBlue();
   JGPoint size = getSize();
   int[] buffer = getPixels();
   // render image to bg depending on bgcol
   BufferedImage img_bg;
   if (bitmask) {
     img_bg = createCompatibleImage(size.x, size.y, Transparency.BITMASK);
   } else {
     img_bg = createCompatibleImage(size.x, size.y, Transparency.TRANSLUCENT);
   }
   int[] bg_buf;
   if (!fast) {
     Graphics g = img_bg.getGraphics();
     g.setColor(bgcol);
     // the docs say I could use bgcol in the drawImage as an
     // equivalent to the following two lines, but this
     // doesn't handle translucency properly and is _slower_
     g.fillRect(0, 0, size.x, size.y);
     g.drawImage(img, 0, 0, null);
     bg_buf = new JREImage(img_bg).getPixels();
   } else {
     bg_buf = buffer;
   }
   // g.dispose();
   // ColorModel rgb_bitmask = ColorModel.getRGBdefault();
   // rgb_bitmask = new PackedColorModel(
   //		rgb_bitmask.getColorSpace(),25,0xff0000,0x00ff00,0x0000ff,
   //		0x1000000, false, Transparency.BITMASK, DataBuffer.TYPE_INT);
   //		ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean
   // isAlphaPremultiplied, int trans, int transferType)
   int[] thrsbuf = new int[size.x * size.y];
   for (int y = 0; y < size.y; y++) {
     for (int x = 0; x < size.x; x++) {
       if (((buffer[y * size.x + x] >> 24) & 0xff) >= thresh) {
         thrsbuf[y * size.x + x] = bg_buf[y * size.x + x] | (0xff << 24);
       } else {
         // explicitly set the colour of the transparent pixel.
         // This makes a difference when scaling!
         // thrsbuf[y*size.x+x]=bg_buf[y*size.x+x]&~(0xff<<24);
         thrsbuf[y * size.x + x] = bgcol_rgb;
       }
     }
   }
   return new JREImage(
       output_comp.createImage(
           new MemoryImageSource(
               size.x,
               size.y,
               // rgb_bitmask,
               img_bg.getColorModel(), // display compatible bitmask
               bitmask ? thrsbuf : bg_buf,
               0,
               size.x)));
 }
コード例 #24
0
  void displayLines(Graphics g, int yStart) {
    // (1 + 2, depends on font size)

    if (isSelection && (xStartSelection != xEndSelection || yStartSelection != yEndSelection)) {
      for (int y = Math.max(0, yStart);
          y < Math.min(yStart + linesOnScreen + 1 + 2, vectorLines.size());
          y++) {
        String currentLine = vectorLines.elementAt(y).toString();
        int width = 0;

        for (int x = 0; x < currentLine.length(); x++) {
          int previousWidth = (x == 0) ? 0 : inputFont.charWidth(currentLine.charAt(x - 1));
          width += previousWidth;

          if (isSelected(x, y)) {
            g.setColor(0x000000);
            g.fillRect(
                width, y * inputHeight, inputFont.charWidth(currentLine.charAt(x)), inputHeight);

            g.setColor(0xffffff);
            g.drawChar(currentLine.charAt(x), width, y * inputHeight, Graphics.LEFT | Graphics.TOP);
          } else {
            g.setColor(0x000000);
            g.drawChar(currentLine.charAt(x), width, y * inputHeight, Graphics.LEFT | Graphics.TOP);
          }
        }

        if (currentLine.length() == 0) {
          if (isSelected(0, y)) {
            g.setColor(0x000000);
            g.fillRect(0, y * inputHeight, 5, inputHeight);
          }
        }
      }
    } else {
      for (int y = Math.max(0, yStart);
          y < Math.min(yStart + linesOnScreen + 1 + 2, vectorLines.size());
          y++) {
        g.drawString(
            vectorLines.elementAt(y).toString(), 0, y * inputHeight, Graphics.LEFT | Graphics.TOP);
      }
    }
  }
コード例 #25
0
ファイル: BaseXLayout.java プロジェクト: adrianber/basex
 /**
  * Draws a visualization tooltip.
  *
  * @param g graphics reference
  * @param tt tooltip label
  * @param x horizontal position
  * @param y vertical position
  * @param w width
  * @param c color color depth
  */
 public static void drawTooltip(
     final Graphics g, final String tt, final int x, final int y, final int w, final int c) {
   final int tw = width(g, tt);
   final int th = g.getFontMetrics().getHeight();
   final int xx = Math.min(w - tw - 8, x);
   g.setColor(color(c));
   g.fillRect(xx - 1, y - th, tw + 4, th);
   g.setColor(BACK);
   g.drawString(tt, xx, y - 4);
 }
コード例 #26
0
ファイル: Game2048.java プロジェクト: Proger666/Neuro2048
 @Override
 public void paint(Graphics g) {
   super.paint(g);
   g.setColor(BG_COLOR);
   g.fillRect(0, 0, this.getSize().width, this.getSize().height);
   for (int y = 0; y < 4; y++) {
     for (int x = 0; x < 4; x++) {
       drawTile(g, myTiles[x + y * 4], x, y);
     }
   }
 }
コード例 #27
0
ファイル: Graph2D.java プロジェクト: corywalker/simuconomy
  /**
   * This paints the entire plot. It calls the draw methods of all the attached axis and data sets.
   * The order of drawing is - Axis first, data legends next, data last.
   *
   * @params g Graphics state.
   */
  public void paint(Graphics g) {
    int i;
    Graphics lg = g.create();
    Rectangle r = bounds();

    /* The r.x and r.y returned from bounds is relative to the
     ** parents space so set them equal to zero.
     */
    r.x = 0;
    r.y = 0;

    if (DefaultBackground == null) DefaultBackground = this.getBackground();
    if (DataBackground == null) DataBackground = this.getBackground();

    //        System.out.println("Graph2D paint method called!");

    if (!paintAll) return;

    r.x += borderLeft;
    r.y += borderTop;
    r.width -= borderLeft + borderRight;
    r.height -= borderBottom + borderTop;

    paintFirst(lg, r);

    if (!axis.isEmpty()) r = drawAxis(lg, r);
    else {
      if (clearAll) {
        Color c = g.getColor();
        g.setColor(DataBackground);
        g.fillRect(r.x, r.y, r.width, r.height);
        g.setColor(c);
      }
      drawFrame(lg, r.x, r.y, r.width, r.height);
    }

    paintBeforeData(lg, r);

    if (!dataset.isEmpty()) {

      datarect.x = r.x;
      datarect.y = r.y;
      datarect.width = r.width;
      datarect.height = r.height;

      for (i = 0; i < dataset.size(); i++) {
        ((DataSet) dataset.elementAt(i)).draw_data(lg, r);
      }
    }

    paintLast(lg, r);

    lg.dispose();
  }
コード例 #28
0
 void displayCurrentCommand(Graphics g) {
   g.setColor(0xffffff);
   g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
   g.setColor(0x000000);
   g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
   g.drawString(
       "Ctrl" + " + " + currentCharCommand,
       0,
       getHeight() - inputHeight,
       Graphics.LEFT | Graphics.TOP);
 }
コード例 #29
0
ファイル: BareGraph.java プロジェクト: maninegi/Java-Projects
  /**
   * This method will draw the axes (if axes mode is on) and the line.
   *
   * @param gc the graphics
   * @see #setAxes
   * @see #setLog
   */
  void drawAll(Graphics gc) {
    Dimension osize = getSize();

    gc.setColor(getBackground());
    gc.fillRect(0, 0, osize.width, osize.height);

    gc.clipRect(0, 0, osize.width, osize.height);

    if (doAxes) {
      gc.setColor(axisColour);
      gc = paintAxis(gc);
    }

    gc.setColor(getBackground());
    gc.fillRect(0, 0, osize.width, osize.height); // trust the clip

    if (dataSet != null) {
      gc.setColor(graphColour);
      paintLine(gc);
    }
  }
コード例 #30
0
ファイル: Process.java プロジェクト: gablank/NTNU
 /**
  * Draws this process as a colored box with a process ID inside.
  *
  * @param g The graphics context.
  * @param x The leftmost x-coordinate of the box.
  * @param y The topmost y-coordinate of the box.
  * @param w The width of the box.
  * @param h The height of the box.
  */
 public void draw(Graphics g, int x, int y, int w, int h) {
   g.setColor(color);
   g.fillRect(x, y, w, h);
   g.setColor(Color.black);
   g.drawRect(x, y, w, h);
   g.setFont(font);
   FontMetrics fm = g.getFontMetrics(font);
   g.drawString(
       "" + processId,
       x + w / 2 - fm.stringWidth("" + processId) / 2,
       y + h / 2 + fm.getHeight() / 2);
 }