示例#1
0
  /** Overrides <code>Graphics.drawRect</code>. */
  public void drawRect(int x, int y, int width, int height) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info().log(toShortString() + " Drawing rect: " + new Rectangle(x, y, width, height));
    }

    if (isDrawingBuffer()) {
      if (debugBuffered()) {
        Graphics debugGraphics = debugGraphics();

        debugGraphics.drawRect(x, y, width, height);
        debugGraphics.dispose();
      }
    } else if (debugFlash()) {
      Color oldColor = getColor();
      int i, count = (info.flashCount * 2) - 1;

      for (i = 0; i < count; i++) {
        graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
        graphics.drawRect(x, y, width, height);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
      graphics.setColor(oldColor);
    }
    graphics.drawRect(x, y, width, height);
  }
示例#2
0
 /** This draws the "Flush 3D Border" which is used throughout the Metal L&F */
 static void drawFlush3DBorder(Graphics g, int x, int y, int w, int h) {
   g.translate(x, y);
   g.setColor(MetalLookAndFeel.getControlDarkShadow());
   g.drawRect(0, 0, w - 2, h - 2);
   g.setColor(MetalLookAndFeel.getControlHighlight());
   g.drawRect(1, 1, w - 2, h - 2);
   g.setColor(MetalLookAndFeel.getControl());
   g.drawLine(0, h - 1, 1, h - 2);
   g.drawLine(w - 1, 0, w - 2, 1);
   g.translate(-x, -y);
 }
示例#3
0
 static void drawDefaultButtonBorder(Graphics g, int x, int y, int w, int h, boolean active) {
   drawButtonBorder(g, x + 1, y + 1, w - 1, h - 1, active);
   g.translate(x, y);
   g.setColor(MetalLookAndFeel.getControlDarkShadow());
   g.drawRect(0, 0, w - 3, h - 3);
   g.drawLine(w - 2, 0, w - 2, 0);
   g.drawLine(0, h - 2, 0, h - 2);
   g.translate(-x, -y);
 }
示例#4
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);
    }
示例#5
0
 static void drawDefaultButtonPressedBorder(Graphics g, int x, int y, int w, int h) {
   drawPressed3DBorder(g, x + 1, y + 1, w - 1, h - 1);
   g.translate(x, y);
   g.setColor(MetalLookAndFeel.getControlDarkShadow());
   g.drawRect(0, 0, w - 3, h - 3);
   g.drawLine(w - 2, 0, w - 2, 0);
   g.drawLine(0, h - 2, 0, h - 2);
   g.setColor(MetalLookAndFeel.getControl());
   g.drawLine(w - 1, 0, w - 1, 0);
   g.drawLine(0, h - 1, 0, h - 1);
   g.translate(-x, -y);
 }
示例#6
0
 void drawZoomIndicator(Graphics g) {
   int x1 = 10;
   int y1 = 10;
   double aspectRatio = (double) imageHeight / imageWidth;
   int w1 = 64;
   if (aspectRatio > 1.0) w1 = (int) (w1 / aspectRatio);
   int h1 = (int) (w1 * aspectRatio);
   if (w1 < 4) w1 = 4;
   if (h1 < 4) h1 = 4;
   int w2 = (int) (w1 * ((double) srcRect.width / imageWidth));
   int h2 = (int) (h1 * ((double) srcRect.height / imageHeight));
   if (w2 < 1) w2 = 1;
   if (h2 < 1) h2 = 1;
   int x2 = (int) (w1 * ((double) srcRect.x / imageWidth));
   int y2 = (int) (h1 * ((double) srcRect.y / imageHeight));
   if (zoomIndicatorColor == null) zoomIndicatorColor = new Color(128, 128, 255);
   g.setColor(zoomIndicatorColor);
   ((Graphics2D) g).setStroke(Roi.onePixelWide);
   g.drawRect(x1, y1, w1, h1);
   if (w2 * h2 <= 200 || w2 < 10 || h2 < 10) g.fillRect(x1 + x2, y1 + y2, w2, h2);
   else g.drawRect(x1 + x2, y1 + y2, w2, h2);
 }
示例#7
0
 public void paint(Graphics g) {
   if (histogram != null) {
     if (os == null) {
       os = createImage(WIDTH, HEIGHT);
       osg = os.getGraphics();
       osg.setColor(Color.white);
       osg.fillRect(0, 0, WIDTH, HEIGHT);
       osg.setColor(Color.gray);
       for (int i = 0; i < WIDTH; i++) {
         if (hColors != null) osg.setColor(hColors[i]);
         osg.drawLine(i, HEIGHT, i, HEIGHT - ((int) (HEIGHT * histogram[i]) / hmax) - 4);
       }
       osg.dispose();
     }
     g.drawImage(os, 0, 0, this);
   } else {
     g.setColor(Color.white);
     g.fillRect(0, 0, WIDTH, HEIGHT);
   }
   g.setColor(Color.black);
   g.drawLine(0, HEIGHT - 4, 256, HEIGHT - 4);
   g.drawRect(0, 0, WIDTH, HEIGHT);
   g.drawRect((int) minHue, 1, (int) (maxHue - minHue), HEIGHT - 5);
 }
示例#8
0
文件: set.java 项目: wcyuan/Set
  public void paint(Graphics g) {
    Message("Copyright Feb, 2000 Weicon Conan Yuan.", "All Rights Reserved", 7);
    for (int i = 0; i < NUM_LOCATIONS; i++) {
      locs[i].draw(g, this);
      g.setColor(txtcolor);
      if (locs[i].ToDraw()) {
        g.drawString("" + i, locs[i].GetX(), locs[i].GetY() + 10);
      }
    }

    g.setColor(Color.red);
    g.drawRect(400, 200, 30, 30);
    g.fillRect(400, 200, 30, 30);
    Message("Cheat", 4);
  }
示例#9
0
文件: set.java 项目: wcyuan/Set
  public void Message(String s, int i) {
    Graphics g = getGraphics();

    if (s == null) {
      g.setColor(bgcolor);
      g.drawRect(400, 50 * i - 10, 200, 10);
      g.fillRect(400, 50 * i - 10, 200, 10);
      return;
    }
    /*
      g.setColor(Color.blue);
      g.drawRect(400,50 * i - 10,200,10);
      g.fillRect(400,50 * i - 10,200,10);
    */
    g.setColor(txtcolor);
    g.drawString(s, 400, 50 * i);
  }
示例#10
0
  static void paintFocus(
      Graphics g, int x, int y, int width, int height, int r1, int r2, float grosor, Color color) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Stroke oldStroke = g2d.getStroke();

    g2d.setColor(color);
    g2d.setStroke(new BasicStroke(grosor));
    if (r1 == 0 && r2 == 0) {
      g.drawRect(x, y, width, height);
    } else {
      g.drawRoundRect(x, y, width - 1, height - 1, r1, r2);
    }

    g2d.setStroke(oldStroke);

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
  }
示例#11
0
 void drawOvalOrRectangle(Graphics g, DrawObject R, boolean isRect) {
   if (R == null) {
     return;
   }
   if ((sequencingOn) && (R.sequenceNum != currentSequenceNumDisplay)) {
     return;
   }
   Graphics2D g2 = (Graphics2D) g;
   g2.setStroke(R.drawStroke);
   int x1 = (int) ((R.x - minX) / (maxX - minX) * (D.width - 2 * inset));
   int y1 = (int) ((R.y - minY) / (maxY - minY) * (D.height - 2.0 * inset));
   double x = R.x + R.width;
   double y = R.y - R.height;
   int x2 = (int) ((x - minX) / (maxX - minX) * (D.width - 2 * inset));
   int y2 = (int) ((y - minY) / (maxY - minY) * (D.height - 2.0 * inset));
   if (isRect) {
     g.drawRect(inset + x1, D.height - y1 - inset, x2 - x1, y1 - y2);
   } else {
     g.drawOval(inset + x1, D.height - y1 - inset, x2 - x1, y1 - y2);
   }
 }
示例#12
0
  public void paintComponent(Graphics g) {
    // We request keyboard focus out here so that we can catch events for locking zoom, etc.
    requestFocus();

    // 3 Images are painted each time. The reason we use images rather than directly drawing
    // onto the graphics context is that the drawings of one image can be taking place
    // concurrently with the other using threads into offscreen graphic contexts assoc.
    // with the respective images. While printing we do the opposite

    if (setupComplete && currImg != null) {
      int prevH = getPrev(currImg.imgIdH);
      int nextH = getNext(currImg.imgIdH);

      if (blFlag || !timer.isRunning()) {
        img[prevH].paintStuff1(0, g, this);
        currImg.paintStuff1(_xPix, g, this);
        img[nextH].paintStuff1(_xPix + _xPix, g, this);

        /*g.drawImage (img [prevH].img, 0, 0, this);
        g.drawImage (img [prevH].timeimg, 0, _yPix, this);

        g.drawImage (currImg.img, _xPix, 0, this);
        g.drawImage (currImg.timeimg, _xPix, _yPix, this);

        g.drawImage (img [nextH].img, _xPix + _xPix, 0, this);
        g.drawImage (img [nextH].timeimg, _xPix + _xPix, _yPix, this);*/
      } else {
        img[prevH].paintStuff2(0, g, this);
        currImg.paintStuff2(_xPix, g, this);
        img[nextH].paintStuff2(_xPix + _xPix, g, this);

        /*g.drawImage (img [prevH].img1, 0, 0, this);
        g.drawImage (img [prevH].timeimg, 0, _yPix, this);

        g.drawImage (currImg.img1, _xPix, 0, this);
        g.drawImage (currImg.timeimg, _xPix, _yPix, this);

        g.drawImage (img [nextH].img1, _xPix + _xPix, 0, this);
        g.drawImage (img [nextH].timeimg, _xPix + _xPix, _yPix, this);*/
      }
    }

    if (zoomLkLineDispStatus && zXTime >= begTime && zXTime <= endTime) {
      int xcord = panePosX + getEvtXCord(zXTime - begTime);
      g.setColor(Color.white);
      g.drawLine(xcord, 0, xcord, _yPix);
      g.fillRect(xcord, _yPix - lineSize, zLockStrW + 2, lineSize);
      g.setColor(Color.black);
      g.drawRect(xcord, _yPix - lineSize, zLockStrW + 1, lineSize - 1);
      g.setColor(Color.red);
      g.drawString("Zoom Lock", xcord + 1, _yPix - fDescent);
    }

    if (elTLineDispStatus && elapsedPoint >= begTime && elapsedPoint <= endTime) {
      int xcord = panePosX + getEvtXCord(elapsedPoint - begTime);
      g.setColor(Color.white);
      g.drawLine(xcord, 0, xcord, _yPix);
      g.fillRect(xcord, _yPix - lineSize, elTimeStrW + 2, lineSize);
      g.setColor(Color.black);
      g.drawRect(xcord, _yPix - lineSize, elTimeStrW + 1, lineSize - 1);
      g.setColor(Color.red);
      g.drawString("Elapsed Time", xcord + 1, _yPix - fDescent);
    }
  }
  @Override
  public void paint(Graphics g) {
    try {
      Graphics2D g2d = (Graphics2D) g;
      if (numPaletteEntries > 50) {
        g2d.setRenderingHint(
            RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
      }
      if (paletteFile != null
          && (paletteFile.toLowerCase().contains("qual")
              || paletteFile.toLowerCase().contains("categorical"))) {
        g2d.setRenderingHint(
            RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
      }
      int width = getWidth();
      int height = getHeight();

      Image image = null;
      int numDisplayedPaletteEntries = 0;
      if (!categorical) {
        numDisplayedPaletteEntries = paletteData.length;
      } else {
        numDisplayedPaletteEntries =
            (int)
                (Math.floor((maxValue - minValue + 1) / numPaletteEntries)
                    + (maxValue - minValue + 1) % numPaletteEntries);
      }
      int[] imageData = new int[numDisplayedPaletteEntries];
      int i, j;
      int numPaletteEntriesLessOne = numPaletteEntries - 1;
      if (!isReversed && orientation == VERTICAL_ORIENTATION) {
        if (!categorical) {
          for (i = 0; i < numPaletteEntries; i++) {
            j =
                (int)
                    ((Math.pow((1 - ((double) (i) / numPaletteEntriesLessOne)), gamma))
                        * numPaletteEntriesLessOne);
            imageData[i] = paletteData[j];
          }
        } else { // it is categorical
          for (i = 0; i < numDisplayedPaletteEntries; i++) {
            j = (int) (i % numPaletteEntries);
            imageData[numDisplayedPaletteEntries - 1 - i] = paletteData[j];
          }
        }
        image = createImage(new MemoryImageSource(1, numDisplayedPaletteEntries, imageData, 0, 1));
      } else if (!isReversed && orientation == HORIZONTAL_ORIENTATION) {
        for (i = 0; i < numPaletteEntries; i++) {
          j =
              (int)
                  ((Math.pow(((double) (i) / numPaletteEntriesLessOne), gamma))
                      * numPaletteEntriesLessOne);
          imageData[i] = paletteData[j];
        }
        image = createImage(new MemoryImageSource(numPaletteEntries, 1, imageData, 0, 1));
      } else if (isReversed && orientation == VERTICAL_ORIENTATION) {
        if (!categorical) {
          for (i = 0; i < numPaletteEntries; i++) {
            j =
                (int)
                    ((Math.pow(((double) (i) / numPaletteEntriesLessOne), gamma))
                        * numPaletteEntriesLessOne);
            imageData[i] = paletteData[j];
          }
        } else { // it is categorical
          for (i = 0; i < numDisplayedPaletteEntries; i++) {
            j = (int) (numPaletteEntries - i % numPaletteEntries - 1);
            imageData[numDisplayedPaletteEntries - 1 - i] = paletteData[j];
          }
        }
        image = createImage(new MemoryImageSource(1, numDisplayedPaletteEntries, imageData, 0, 1));
      } else if (isReversed && orientation == HORIZONTAL_ORIENTATION) {
        for (i = 0; i < numPaletteEntries; i++) {
          j =
              (int)
                  ((Math.pow((1 - ((double) (i) / numPaletteEntriesLessOne)), gamma))
                      * numPaletteEntriesLessOne);
          imageData[i] = paletteData[j];
        }
        image = createImage(new MemoryImageSource(imageData.length, 1, imageData, 0, 1));
      }

      g.drawImage(image, 0, 0, width, height, this);
      if (!isSelected) {
        g.setColor(Color.black);
        g.drawRect(0, 0, width - 1, height - 1);
      } else {
        g.setColor(Color.white);
        g.drawRect(1, 1, width - 3, height - 3);
        g.setColor(Color.red);
        g.drawRect(0, 0, width - 1, height - 1);
      }
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }
  }
示例#14
0
 private void drawStartBox(Graphics g) {
   if (type != ANGLE) {
     double offset = getOffset(0.5);
     g.drawRect(ic.screenXD(startXD + offset) - 4, ic.screenYD(startYD + offset) - 4, 8, 8);
   }
 }
示例#15
0
  public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    // for antialising geometric shapes
    g2d.addRenderingHints(
        new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
    // for antialiasing text
    g2d.setRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    g.drawImage(this.boardImage, 0, 0, null);

    if (this.drawGrid) {
      for (int x = 0; x < 24; x++) {
        for (int y = 0; y < 29; y++) {
          g.setColor(Color.RED);
          g.drawRect(
              (int) ((x * GUI.xSize) + GUI.xOffset),
              (int) ((y * GUI.ySize) + GUI.yOffset),
              (int) GUI.xSize,
              (int) GUI.ySize);
        }
      }
    }

    if (ui.chooseMovementsMode) {
      for (int x = 0; x < 24; x++) {
        for (int y = 0; y < 29; y++) {
          if (ui.moveables[x][y] == 1) g.setColor(new Color(0, 255, 0, 60));
          else if (ui.moveables[x][y] == 2) g.setColor(new Color(0, 0, 255, 80));
          else continue;

          g.fillRect(
              (int) Math.ceil((x * GUI.xSize) + GUI.xOffset),
              (int) Math.ceil((y * GUI.ySize) + GUI.yOffset),
              (int) Math.ceil(GUI.xSize),
              (int) Math.ceil(GUI.ySize));
        }
      }
    }

    for (Character c : Character.characters) {
      System.out.printf("%d %d\n", c.X, c.Y);
      Color targetColour = Color.BLACK;

      /*
       * new Character("Kasandra Scarlet", 18, 28),
      new Character("Jack Mustard", 7, 28),
      new Character("Diane White", 0, 19),
      new Character("Jacob Green", 0, 9),
      new Character("Eleanor Peacock", 20, 0),
      new Character("Victor Plum", 6, 0)
      */

      if (c == Character.characters[0]) targetColour = scarletColor;
      else if (c == Character.characters[1]) targetColour = mustardColor;
      else if (c == Character.characters[2]) targetColour = whiteColor;
      else if (c == Character.characters[3]) targetColour = greenColor;
      else if (c == Character.characters[4]) targetColour = peacockColor;
      else if (c == Character.characters[5]) targetColour = plumColor;

      g.setColor(targetColour);

      g.fillOval(
          GUI.getCoordFromBoardX(c.X) + 2,
          GUI.getCoordFromBoardY(c.Y) + 2,
          (int) (GUI.xSize - 4),
          (int) (GUI.ySize - 4));
      g.setColor(Color.BLACK);
      g.drawOval(
          GUI.getCoordFromBoardX(c.X) + 2,
          GUI.getCoordFromBoardY(c.Y) + 2,
          (int) (GUI.xSize - 4),
          (int) (GUI.ySize - 4));
    }
  }
示例#16
0
  private void drawLayout(Graphics g) {
    g.setColor(Color.blue);
    g.drawRect(10, 10, width - 20, height - 20);

    g.setColor(Color.red.brighter());
    Iterator f = players.iterator();
    int lifeDisplayPosition = 0;
    while (f.hasNext()) {
      Player h = (Player) f.next();
      if (h.isActive()) {
        lifeDisplayPosition++;
        String lifeInformation = "Player " + lifeDisplayPosition + ": ";
        for (int i = 0; i < h.getLives(); i++) {
          lifeInformation += "\u2606";
        }
        g.drawString(lifeInformation, 20, lifeDisplayPosition * 40);
      }
    }

    borders[2] = width - 20;
    borders[3] = height - 20;

    Iterator i = players.iterator();
    Player p;
    while (i.hasNext()) {
      p = (Player) i.next();
      if (p.isActive()
          && !countdownF
          && (p.getX() < borders[0]
              || p.getY() < borders[1]
              || p.getX() > borders[2]
              || p.getY() > borders[3])
          && (!p.getImmunity())) {
        p.decLives(width / 2, height / 2);
        p.setImmunity(true);
      }
      if (p.getLives() <= 0) {
        if (p instanceof MouseControlledPlayer) {
          MouseControlledPlayer m = (MouseControlledPlayer) p;
          removeMouseListener(m);
          removeMouseMotionListener(m);
        } else if (p instanceof KeyboardControlledPlayer) {
          KeyboardFocusManager.getCurrentKeyboardFocusManager()
              .removeKeyEventDispatcher((KeyboardControlledPlayer) p);
        }
        i.remove();
        for (int h = 0; h < 4; h++) {
          if (deathLocation[h] == -1) {
            deathLocation[h] = p.getX();
            deathLocation[h + 1] = p.getY();
            break;
          }
        }
      }
    }

    if ((deathLocation[0] != -1) && (deathLocation[1] != -1)) {
      g.drawLine(
          deathLocation[0] - 15,
          deathLocation[1] - 15,
          deathLocation[0] + 15,
          deathLocation[1] + 15);
      g.drawLine(
          deathLocation[0] + 15,
          deathLocation[1] - 15,
          deathLocation[0] - 15,
          deathLocation[1] + 15);
    }
    if ((deathLocation[2] != -1) && (deathLocation[3] != -1)) {
      g.drawLine(
          deathLocation[2] - 15,
          deathLocation[3] - 15,
          deathLocation[2] + 15,
          deathLocation[3] + 15);
      g.drawLine(
          deathLocation[2] + 15,
          deathLocation[3] - 15,
          deathLocation[2] - 15,
          deathLocation[3] + 15);
    }

    if (!onePlayerAlive) {
      Font old = g.getFont();
      g.setFont(new Font("monospaced", Font.BOLD, 20));
      g.setColor(Color.red.darker());
      g.drawString("GAME OVER", width / 2 - 40, height / 2);
      g.setFont(old);
      g.setColor(Color.WHITE);
      g.drawString("Score", width - 60, 25);
      g.drawString(String.valueOf(score), width - 60, 40);
    }
  }
示例#17
0
 static void drawDisabledBorder(Graphics g, int x, int y, int w, int h) {
   g.translate(x, y);
   g.setColor(MetalLookAndFeel.getControlShadow());
   g.drawRect(0, 0, w - 1, h - 1);
   g.translate(-x, -y);
 }