Ejemplo n.º 1
0
 private void placerPostes(Graphics2D g) {
   g.setStroke(new BasicStroke());
   for (PlanSalle.Poste poste : modele.listerPostes()) {
     g.setColor(Color.gray);
     int xPoste = Parametres.posteX(poste.getPosition().getTravee(), poste.getOrientation());
     int yPoste = Parametres.posteY(poste.getPosition().getRangee(), poste.getOrientation());
     int xPersonne =
         Parametres.personneX(poste.getPosition().getTravee(), poste.getOrientation());
     int yPersonne =
         Parametres.personneY(poste.getPosition().getRangee(), poste.getOrientation());
     if (poste.getOrientation() == Orientation.NORD
         || poste.getOrientation() == Orientation.SUD) {
       g.fill3DRect(xPoste, yPoste, Parametres.LONGUEUR_POSTE, Parametres.LARGEUR_POSTE, true);
     } else {
       g.fill3DRect(xPoste, yPoste, Parametres.LARGEUR_POSTE, Parametres.LONGUEUR_POSTE, true);
     }
     g.drawOval(xPersonne, yPersonne, Parametres.LARGEUR_PERSONNE, Parametres.LARGEUR_PERSONNE);
     if (poste.peutVoir()) {
       g.setColor(Color.red);
     } else {
       g.setColor(Color.blue);
     }
     g.fillOval(xPersonne, yPersonne, 20, 20);
   }
 }
Ejemplo n.º 2
0
 private void createButtonRect(Graphics2D g, boolean raised) {
   Color oldColor = g.getColor();
   g.setColor(this.ButtonColor);
   g.fill3DRect(
       (int) super.getX(), (int) super.getY(), this.ButtonWidth, this.ButtonHeight, raised);
   g.setColor(oldColor);
 }
Ejemplo n.º 3
0
  public void paintComponent(Graphics g) {

    GradientPaint gradient = new GradientPaint(70, 70, Color.blue, 150, 150, Color.orange);
    Image image = new ImageIcon("a.jpg").getImage();
    Random generator = new Random();

    int x1 = generator.nextInt(200) + 1;
    int y1 = generator.nextInt(200) + 1;
    int x2 = x1 + generator.nextInt(100) + 1;
    int y2 = x1 + generator.nextInt(100) + 1;

    g.setColor(Color.blue);
    g.fillRect(70, 70, 200, 100);

    g.setColor(Color.black);
    g.fillOval(80, 80, 170, 70);

    Graphics2D g2d = (Graphics2D) g;

    g.setColor(Color.yellow);
    g2d.fill3DRect(10, 10, 100, 100, true);

    g.drawImage(image, 300, 300, this);

    g2d.setPaint(gradient);
    g2d.fillOval(x1, y1, x2, y2);
  }
Ejemplo n.º 4
0
 public static javax.swing.Icon getIconFromColor(java.awt.Color color, int width, int height) {
   java.awt.image.BufferedImage colorImage =
       new java.awt.image.BufferedImage(width, height, java.awt.image.BufferedImage.TYPE_INT_RGB);
   java.awt.Graphics2D g = colorImage.createGraphics();
   g.setColor(color);
   g.fill3DRect(0, 0, width, height, true);
   return new javax.swing.ImageIcon(colorImage);
 }
Ejemplo n.º 5
0
 @Override
 public void paint(Graphics g, int x, int y, double scale) {
   g.setColor(getColor());
   Graphics2D gg = (Graphics2D) g;
   int w = 3;
   if (selected) w = 4;
   g.drawLine(x, getY0(), x, getY1());
   gg.fill3DRect(x - w, y - w, 2 * w, 2 * w, true);
 }
  protected void showWell(int c, int r, Graphics2D g, Color color, boolean fill) {
    int y = (int) (((r / BUCKET - 1) * pixperrow));
    int x = (int) (BORDER + (c / BUCKET * pixpercol));
    g.setColor(color);
    if (fill) {
      g.fill3DRect(x - 1, y - 1, (int) pixpercol + 2, (int) pixperrow + 2, true);
    } else {
      g.draw3DRect(x - 1, y - 1, (int) pixpercol + 2, (int) pixperrow + 2, true);
    }

    // g.drawString("" + value, x, maxy - starty + 3);
  }
Ejemplo n.º 7
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (w.n == Player) {
     sendInfo();
   }
   if (valid()) {
     if (ok) {
       changePlayer();
       ok = false;
       if (bile[0].bila == null) bile[0] = new Bila(x, y, this);
       if (w.n > 0) sendInfo();
     }
   }
   g.drawImage(masa, 0, 0, null);
   Graphics2D g2 = (Graphics2D) g;
   g2.setColor(new Color(0xC0C0C0));
   g2.fillRect(103, 15, 70, 23);
   g2.setColor(Color.BLACK);
   g2.setFont(new Font("Algerian", Font.ITALIC, 20));
   g2.drawString("Player" + Player, 100, 32);
   g2.setColor(Color.WHITE);
   g2.setFont(new Font("Algerian", Font.BOLD, 40));
   g2.drawString("Russian Billiard", 230, 50);
   g2.setColor(Color.GRAY);
   g2.fillRect(12, 443, 286, 25);
   g2.fillRect(341, 443, 286, 25);
   for (int i = 1; i < bile.length; i++)
     g2.drawImage(bBall, (int) bile[i].xp - dim, (int) bile[i].yp - dim, DIM, DIM, null);
   g2.setColor(Color.DARK_GRAY);
   g2.setStroke(new BasicStroke(6));
   g2.drawRoundRect(12, 443, 286, 25, 3, 3);
   g2.drawRoundRect(341, 443, 286, 25, 3, 3);
   g2.clip(new Ellipse2D.Double(17, 15, 77, 77));
   for (int i = 0; i < Putere; i++) {
     g2.setColor(new Color(6 * i, 200, 255 - 6 * i));
     g2.fill3DRect(17, 91 - i * d, 77, d, true);
   }
   g2.setClip(null);
   g2.setStroke(new BasicStroke());
   if (bile[0].bila != null)
     g2.drawImage(rBall, (int) bile[0].xp - dim, (int) bile[0].yp - dim, DIM, DIM, null);
   if (Tinta != null) {
     g2.rotate(Math.atan2(Tinta.y - bile[0].yp, Tinta.x - bile[0].xp), bile[0].xp, bile[0].yp);
     g2.drawImage(cue, (int) bile[0].xp + dim + Putere, (int) bile[0].yp - dim / 3, 200, 10, null);
   }
   if (player[0] == 6 || player[1] == 6 || (player[0] == 5 && player[1] == 5)) {
     for (int i = 0; i < bile.length; i++) bile[i].stop();
     reset();
   }
 }
Ejemplo n.º 8
0
  private static void paintRectangle2D(Graphics g, RemoteRectangle rectangle, boolean fill) {

    Graphics2D g2d = (Graphics2D) g;
    try {
      if (rectangle.isRounded()) {
        paintRoundedRectangle2D(g, rectangle, fill);
        return;
      }
      // Rectangle bounds = rectangle.getBounds();
      Rectangle2D.Double rectangle2D =
          new Rectangle2D.Double(
              rectangle.getX(), rectangle.getY(), rectangle.getWidth(), rectangle.getHeight());

      if (fill) {
        g2d.fill(rectangle2D);
        Color origColor = g.getColor();
        g.setColor(Color.BLACK);
        if (rectangle.is3D())
          g2d.fill3DRect(
              rectangle.getX(),
              rectangle.getY(),
              rectangle.getWidth(),
              rectangle.getHeight(),
              rectangle.isRaised());
        else g2d.draw(rectangle2D);
        g.setColor(origColor);
        // g2d.draw(rectangle2D);
      } else {
        if (rectangle.is3D())
          g2d.draw3DRect(
              rectangle.getX(),
              rectangle.getY(),
              rectangle.getWidth(),
              rectangle.getHeight(),
              rectangle.isRaised());
        else g2d.draw(rectangle2D);
      }
    } catch (Exception e) {
      e.printStackTrace();
      // System.out.println(e);
    }
  }
Ejemplo n.º 9
0
    protected BufferedImage makeImage() {
      BufferedImage image =
          new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, BufferedImage.TYPE_4BYTE_ABGR);
      Graphics2D g = image.createGraphics();

      g.setPaint(Color.WHITE);
      g.fill3DRect(0, 0, IMAGE_SIZE, IMAGE_SIZE, false);

      g.setPaint(Color.RED);
      g.setFont(Font.decode("ARIAL-BOLD-50"));

      g.drawString(Long.toString(++this.counter) + " frames", 10, IMAGE_SIZE / 4);
      g.drawString(
          Long.toString((System.currentTimeMillis() - start) / 1000) + " sec", 10, IMAGE_SIZE / 2);
      g.drawString(
          "Heap:" + Long.toString(Runtime.getRuntime().totalMemory()), 10, 3 * IMAGE_SIZE / 4);

      g.dispose();

      return image;
    }
Ejemplo n.º 10
0
 private void frame(Graphics2D g, int x, int y, int w, int h) {
   g.fill3DRect(x, y, w, h, true);
   g.fill3DRect(x + 2, y + 2, w - 4, h - 4, false);
   g.fillRect(x + 3, y + 3, w - 6, h - 6);
 }
Ejemplo n.º 11
0
 // also clip, transform, composite,
 // public boolean isOpaque(){return false;}//theOpaque!=null&&theOpaque;}
 // ---------------------------------------------------------
 private void doPaint(Graphics2D g, int s, Object o) {
   // process an operation from the buffer
   // System.out.println(s);
   Object o1 = null,
       o2 = null,
       o3 = null,
       o4 = null,
       o5 = null,
       o6 = null,
       o7 = null,
       o8 = null,
       o9 = null,
       o10 = null,
       o11 = null;
   if (o instanceof Object[]) {
     Object[] a = (Object[]) o;
     if (a.length > 0) o1 = a[0];
     if (a.length > 1) o2 = a[1];
     if (a.length > 2) o3 = a[2];
     if (a.length > 3) o4 = a[3];
     if (a.length > 4) o5 = a[4];
     if (a.length > 5) o6 = a[5];
     if (a.length > 6) o7 = a[6];
     if (a.length > 7) o8 = a[7];
     if (a.length > 8) o9 = a[8];
     if (a.length > 9) o10 = a[9];
     if (a.length > 10) o11 = a[10];
   }
   switch (s) {
     case clear:
       paintBackground(g, theBackground);
       break;
       // public void addRenderingHints(Map<?,?> hints)
       // {toBuffer("addRenderingHints",hints );}
     case addRenderingHints:
       g.addRenderingHints((Map<?, ?>) o);
       break;
     case clip1:
       g.clip((Shape) o);
       break;
     case draw1:
       g.draw((Shape) o);
       break;
     case draw3DRect:
       g.draw3DRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Boolean) o5);
       break;
     case drawGlyphVector:
       g.drawGlyphVector((GlyphVector) o1, (Float) o2, (Float) o3);
       break;
     case drawImage1:
       g.drawImage((BufferedImage) o1, (BufferedImageOp) o2, (Integer) o3, (Integer) o4);
       break;
     case drawImage2:
       g.drawImage((Image) o1, (AffineTransform) o2, (ImageObserver) o3);
       break;
     case drawRenderableImage:
       g.drawRenderableImage((RenderableImage) o1, (AffineTransform) o2);
       break;
     case drawRenderedImage:
       g.drawRenderedImage((RenderedImage) o1, (AffineTransform) o2);
       break;
     case drawString1:
       g.drawString((AttributedCharacterIterator) o1, (Float) o2, (Float) o3);
       break;
     case drawString2:
       g.drawString((AttributedCharacterIterator) o1, (Integer) o2, (Integer) o3);
       break;
     case drawString3:
       g.drawString((String) o1, (Float) o2, (Float) o3);
       break;
     case drawString4:
       g.drawString((String) o1, (Integer) o2, (Integer) o3);
       break;
     case fill:
       g.fill((Shape) o);
       break;
     case fill3DRect:
       g.fill3DRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Boolean) o5);
       break;
     case rotate1:
       g.rotate((Double) o);
       break;
     case rotate2:
       g.rotate((Double) o1, (Double) o2, (Double) o3);
       break;
     case scale1:
       g.scale((Double) o1, (Double) o2);
       break;
     case setBackground:
       g.setBackground(
           (Color) o); // paintBackground(g,(Color)o); /*super.setBackground((Color)o) ;*/
       break;
     case setComposite:
       g.setComposite((Composite) o);
       break;
     case setPaint:
       g.setPaint((Paint) o);
       break;
     case setRenderingHint:
       g.setRenderingHint((RenderingHints.Key) o1, o2);
       break;
     case setRenderingHints:
       g.setRenderingHints((Map<?, ?>) o);
       break;
     case setStroke:
       g.setStroke((Stroke) o);
       break;
     case setTransform:
       g.setTransform(makeTransform(o));
       break;
     case shear:
       g.shear((Double) o1, (Double) o2);
       break;
     case transform1:
       g.transform(makeTransform(o));
       break;
     case translate1:
       g.translate((Double) o1, (Double) o2);
       break;
     case translate2:
       g.translate((Integer) o1, (Integer) o2);
       break;
     case clearRect:
       g.clearRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case copyArea:
       g.copyArea(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case drawArc:
       g.drawArc(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case drawBytes:
       g.drawBytes((byte[]) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5);
       break;
     case drawChars:
       g.drawChars((char[]) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5);
       break;
     case drawImage4:
       g.drawImage((Image) o1, (Integer) o2, (Integer) o3, (Color) o4, (ImageObserver) o5);
       break;
     case drawImage5:
       g.drawImage((Image) o1, (Integer) o2, (Integer) o3, (ImageObserver) o4);
       break;
     case drawImage6:
       g.drawImage(
           (Image) o1,
           (Integer) o2,
           (Integer) o3,
           (Integer) o4,
           (Integer) o5,
           (Color) o6,
           (ImageObserver) o7);
       break;
     case drawImage7:
       g.drawImage(
           (Image) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (ImageObserver) o6);
       break;
     case drawImage8:
       g.drawImage(
           (Image) o1,
           (Integer) o2,
           (Integer) o3,
           (Integer) o4,
           (Integer) o5,
           (Integer) o6,
           (Integer) o7,
           (Integer) o8,
           (Integer) o9,
           (Color) o10,
           (ImageObserver) o11);
       break;
     case drawImage9:
       g.drawImage(
           (Image) o1,
           (Integer) o2,
           (Integer) o3,
           (Integer) o4,
           (Integer) o5,
           (Integer) o6,
           (Integer) o7,
           (Integer) o8,
           (Integer) o9,
           (ImageObserver) o10);
       break;
     case drawLine:
       g.drawLine((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case drawOval:
       g.drawOval((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case drawPolygon1:
       g.drawPolygon((int[]) o1, (int[]) o2, (Integer) o3);
       break;
     case drawPolygon2:
       g.drawPolygon((Polygon) o);
       break;
     case drawPolyline:
       g.drawPolyline((int[]) o1, (int[]) o2, (Integer) o3);
       break;
     case drawRect:
       g.drawRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case drawRoundRect:
       g.drawRoundRect(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case fillArc:
       g.fillArc(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case fillOval:
       g.fillOval((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
       // {toBuffer("fillPolygon",mkArg(xPoints,  yPoints, nPoints) );}
     case fillPolygon1:
       g.fillPolygon((int[]) o1, (int[]) o2, (Integer) o3);
       break;
     case fillPolygon2:
       g.fillPolygon((Polygon) o);
       break;
     case fillRect:
       g.fillRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case fillRoundRect:
       g.fillRoundRect(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case setClip1:
       g.setClip((Shape) o);
       break;
     case setColor:
       g.setColor((Color) o);
       break;
     case setFont:
       g.setFont((Font) o);
       break;
     case setPaintMode:
       g.setPaintMode();
       break;
     case setXORMode:
       g.setXORMode((Color) o);
       break;
     case opaque:
       super.setOpaque((Boolean) o);
       break;
     case drawOutline: // g.drawString((String)o1, (Integer)o2, (Integer)o3) ;break;
       {
         FontRenderContext frc = g.getFontRenderContext();
         TextLayout tl = new TextLayout((String) o1, g.getFont(), frc);
         Shape s1 = tl.getOutline(null);
         AffineTransform af = g.getTransform();
         g.translate((Integer) o2, (Integer) o3);
         g.draw(s1);
         g.setTransform(af);
       }
       ;
       break;
     default:
       System.out.println("Unknown image operation " + s);
   }
 }
  public void draw(Graphics g) {

    Graphics2D graphics = (Graphics2D) g; // s.getGraphics();
    graphics.setPaint(color);
    graphics.fill3DRect(xPosition, 0, barWidth, value, false);
  }