示例#1
0
 public PanelColor(int id, Fenetre f, DisplayColor dc, Button backButton, int w, int h) {
   this.estConstructeurBis = true;
   this.bgColor = dc.getBackground();
   this.dc = dc;
   this.setBounds(0, 0, w, h);
   this.lastButton = backButton;
   this.setBackground(this.bgColor);
   this.add(colorB);
   this.add(colorG);
   this.add(colorR);
   System.out.println(this.lastButton);
   this.colorB.setColor("" + this.lastButton.getColor().getBlue());
   this.colorR.setColor("" + this.lastButton.getColor().getRed());
   this.colorG.setColor("" + this.lastButton.getColor().getGreen());
   this.colorChoice.setBackground(lastButton.getColor());
   this.next.setId(lastButton.getId());
   choseColor.addMouseListener(this);
   this.add(choseColor);
   // this.add(this.numColor);
   this.frame = f;
   this.setSize(new Dimension(w, h));
   this.setLayout(null);
   this.addMouseListener(this);
   // carreColor.setMaximumSize(new Dimension(200, 200));
   this.add(carreColor);
   validColor(colorR.getColor(), colorG.getColor(), colorB.getColor());
   this.add(colorChoice);
   this.next.addMouseListener(this);
   this.add(next);
   neededGrey = maxGrey / (frame.getNmbColor());
   frame.setNeededGrey(neededGrey);
 }
示例#2
0
 public PanelColor(Fenetre f, String name, int nbColor, Color c, int w, int h) {
   this.bgColor = c;
   choseColor.addMouseListener(this);
   this.add(choseColor);
   this.nmbColor = nbColor - 1;
   this.numColor.setText(this.numColor.getText() + this.nmbColor + " couleur(s)");
   this.add(this.numColor);
   this.frame = f;
   this.setBackground(this.bgColor);
   this.setSize(new Dimension(w, h));
   this.setName(name);
   this.setLayout(null);
   this.addMouseListener(this);
   // carreColor.setMaximumSize(new Dimension(200, 200));
   this.add(carreColor);
   System.out.println(this.carreColor.getBackground());
   this.add(colorR);
   validColor(colorR.getColor(), colorG.getColor(), colorB.getColor());
   this.add(colorChoice);
   this.next.addMouseListener(this);
   this.add(next);
   this.add(colorB);
   this.add(colorG);
   neededGrey = maxGrey / (frame.getNmbColor());
   frame.setNeededGrey(neededGrey);
   frame.map.put(frame.getGreyIndicator(), this);
 }
 @Override
 public Position reArrangeRelativePosition(Player oldPlayerPos, Player newPlayerPos) {
   int different = this.ordinal() + getDeviation(oldPlayerPos);
   if (different < 0) {
     different = ELEMENTSINCYCLE - different;
   }
   return Button.values()[(different % ELEMENTSINCYCLE)].getRelativePosition(newPlayerPos);
 }
 public Button getRelativePosition(Player myPos) {
   Button answer = this;
   switch (myPos) {
     case TOP:
       {
         answer = Button.values()[(this.ordinal() + TOPDEVIATION) % ELEMENTSINCYCLE];
         break;
       }
     case RIGHT:
       {
         answer = Button.values()[(this.ordinal() + RIGHTDEVIATION) % ELEMENTSINCYCLE];
         break;
       }
     case LEFT:
       {
         answer = Button.values()[(this.ordinal() + LEFTDEVIATION) % ELEMENTSINCYCLE];
         break;
       }
     default:
       {
       }
   }
   return answer;
 }
示例#5
0
  @Override
  public void mouseClicked(MouseEvent arg0) {
    Button b;
    if (arg0.getSource() instanceof Button) {
      b = (Button) arg0.getSource();
      int red = this.stringToInt(this.colorR.getText());
      int green = this.stringToInt(this.colorG.getText());
      int blue = this.stringToInt(this.colorB.getText());
      if (arg0.getSource() == next) {
        if (this.nmbColor != 0) {
          this.frame.getDC().addColor(new Color(red, green, blue));
          b.setColor(this.colorChoice.getBackground());
          this.frame.setContentPane(
              new PanelColor(
                  this.frame,
                  "menuColorChoice",
                  this.nmbColor,
                  this.bgColor,
                  this.getWidth(),
                  this.getHeight()));
        } else {
          if (estConstructeurBis == true) {
            System.out.println("id ===== " + b.getId());
            dc.getButtonList().get(b.getId()).setBackground(new Color(red, green, blue));
            dc.getButtonList().get(b.getId()).setColor(new Color(red, green, blue));
            // dc.getButtonList().set(b.getId(), b);
            dc.repaint();
            // this.frame.getDC().updatePanel();
            this.frame.setContentPane(dc);
            dc.repaint();
            this.frame.revalidate();
            estConstructeurBis = false;
          } else {
            this.frame
                .getDC()
                .addColor(
                    new Color(
                        this.stringToInt(this.colorR.getText()),
                        this.stringToInt(this.colorG.getText()),
                        this.stringToInt(this.colorB.getText())));
            b.setColor(this.colorChoice.getBackground());
            this.frame.getDC().updatePanel();
            this.frame.setContentPane(this.frame.getDC());
          }
        }

        frame.setGreyIndicator(neededGrey);
        this.frame.revalidate();
      } else if (arg0.getSource() == choseColor) {
        PrecisePanel p =
            new PrecisePanel(
                this.frame, this, this.getBackground(), 0, 0, this.getWidth(), this.getHeight());
        this.frame.setContentPane(p);
        this.frame.revalidate();
      } else {
        System.out.println(colorR.getText() + " " + colorG.getText() + " " + colorB.getText());
        this.colorR.setColor(colorR.getText());
        this.colorG.setColor(colorG.getText());
        this.colorB.setColor(colorB.getText());
        validColor(colorR.getColor(), colorG.getColor(), colorB.getColor());
        this.colorR.setText("" + colorR.getColor());
        this.colorG.setText("" + colorG.getColor());
        this.colorB.setText("" + colorB.getColor());
        this.repaint();
      }
    }
  }