<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with setimages() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=setimages%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:56:59 +0000</pubDate>
         <description>Tagged with setimages() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedsetimages%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Removing mouseover state in controlP5</title>
      <link>https://forum.processing.org/two/discussion/27703/removing-mouseover-state-in-controlp5</link>
      <pubDate>Fri, 06 Apr 2018 13:16:27 +0000</pubDate>
      <dc:creator>steve_j</dc:creator>
      <guid isPermaLink="false">27703@/two/discussions</guid>
      <description><![CDATA[<p>Having a small problem with controlP5 in android. The first press of a button triggers the mouseoverstate and not a trigger of the button. Is there anyway to bypass this? I have tried to set the mouseOver to true but doesnt help.</p>

<p>The three image files are being used for debug. Really i only need two.</p>

<pre><code>PImage[] imgsMinus = {loadImage("Volume-2.png"), loadImage("Volume-1.png"), loadImage("Volume.png")};
PImage[] imgsPlus = {loadImage("Volume-2.png"), loadImage("Volume-1.png"), loadImage("Volume.png")};

cp5.addButton("down")
      .setValue(-1)
      .setMouseOver(true)
      .setImages(imgsMinus)
      .updateSize()
      .setPosition(100, 100)

cp5.addButton("UP")
      .setValue(1)
      .setMouseOver(true)
      .setImages(imgsPlus)
      .updateSize()
      .setPosition(100, 100)
</code></pre>
]]></description>
   </item>
   <item>
      <title>using .setSize() with controlP5 imageButtons</title>
      <link>https://forum.processing.org/two/discussion/17848/using-setsize-with-controlp5-imagebuttons</link>
      <pubDate>Mon, 15 Aug 2016 07:53:00 +0000</pubDate>
      <dc:creator>deano</dc:creator>
      <guid isPermaLink="false">17848@/two/discussions</guid>
      <description><![CDATA[<p>Hi there guys, here is the default example for imageButton with ControlP5. (one can find it under Examples)</p>

<p>I was wondering if there was a way to scale up/down say the rolloverImage by a few pixels. So that when you rollover with your mouse the button appears to pop in place.</p>

<p>I tried .setSize(int,int) before .updateSize(); but it does nothing. If you remove the line .updateSize() it freezes.</p>

<p>Any ideas? Tried the java docs but unsure of the syntax/method here.</p>

<pre><code>import controlP5.*;

ControlP5 cp5;

int myColor = color(0);


void setup() {
  size(400, 600);
  cp5 = new ControlP5(this);

  // replace the default controlP5 button with an image.
  // button.setImages(defaultImage, rolloverImage, pressedImage);
  // use button.updateSize() to adjust the size of the button and 
  // resize to the dimensions of the defaultImage

  cp5.addButton("buttonA")
    .setPosition(175, 275)
      .setImages(loadImage("Arrow-Left.png"), loadImage("Arrow-Right.png"), loadImage("Refresh.png"))
        .updateSize();
}

void draw() {
  background(myColor);
}

public void controlEvent(ControlEvent theEvent) {
  println(theEvent.getController().getName());
}

// function buttonA will receive changes from 
// controller with name buttonA
public void buttonA(int theValue) {
  println("a button event from buttonA: "+theValue);
  myColor = color(128);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>ControlP5 I am misunderstanding something</title>
      <link>https://forum.processing.org/two/discussion/17376/controlp5-i-am-misunderstanding-something</link>
      <pubDate>Thu, 30 Jun 2016 23:27:22 +0000</pubDate>
      <dc:creator>Sark</dc:creator>
      <guid isPermaLink="false">17376@/two/discussions</guid>
      <description><![CDATA[<p>Hello, 
I am a rusty programmer.. I was wondering if someone would be kind enough to point out my misunderstanding.
I am setting up two windows.. one running a temperature graph and one containing the controls.  There are three temp stations.  Everything was running along smoothly until I tried using the setOn() or setOff() button functions.  I think I am misunderstanding something basic about how the ControlP5 library works.</p>

<p>There is a lot of irrelevant code... I think this should be enough to help me...if you so choose.</p>

<pre><code>        `
        SecondWin sw;

        void settings() {
           size(1100, 850, JAVA2D);  
        }

        void setup() {
           sw = new SecondWin(this, 700, 400);  //second Window (Control Panel)
        }
        void draw() {  
        }

        public class SecondWin extends PApplet {  // code for window

          int w, h;
          PApplet parent;
          ControlP5 cp5;


            public SecondWin(PApplet _parent, int _w, int _h) {
               super();
               parent = _parent;

               w = _w;
               h = _h;
               PApplet.runSketch(new String[]{this.getClass().getName()}, this);
            }

            public void settings() {
               size(w, h); 
            }

            public void setup() {

            cp5 = new ControlP5(this);

              cp5.addButton("VS2")
                            .setImages(icons[0], icons[0], icons[10])
                            .updateSize()
                            .setPosition(10, 10)
                            .setSwitch(true)
                            .setId(50)
                            .plugTo(parent, "VS2");
        }

          public void draw() {
          background(255);
          fill(0);
         }
         public void controlEvent(ControlEvent theEvent) {
              if (theEvent.isController()) {
                  println(((Button)cp5.getController("VS2")).isOn());
       //         ((Button)cp5.getController("VS2")).setOn();       ########## PROBLEM  ######
            }

        }
}
`
</code></pre>

<p>As mentioned, I left out a lot of code.  I have been fighting this for a few hours...so a lot of this code I have stolen from online sources and Frankenstein'd here.</p>

<p>As is, it runs with no errors and hitting the VS2 button prints out the proper false and true values.
When I un-comment the ((Button)cp5.getController("VS2")).setOn();  and then hit the button, I get a stream of multiple 'trues' printed to console and</p>

<pre><code>    java.lang.NoClassDefFoundError: Could not initialize class java.util.logging.LogRecord
at java.util.logging.Logger.log(Logger.java:787)
at java.util.logging.Logger.severe(Logger.java:1463)
at controlP5.ControlBroadcaster.printMethodError(Unknown Source)
at controlP5.ControlBroadcaster.invokeMethod(Unknown Source)
at controlP5.ControlBroadcaster.broadcast(Unknown Source)
at controlP5.Controller.broadcast(Unknown Source)
at controlP5.Button.setValue(Unknown Source)
at controlP5.Button.activate(Unknown Source)
at controlP5.Button.mouseReleased(Unknown Source)
at controlP5.Controller.setMousePressed(Unknown Source)
at controlP5.ControllerGroup.setMousePressed(Unknown Source)
at controlP5.ControlWindow.mouseReleasedEvent(Unknown Source)
at controlP5.ControlWindow.mouseEvent(Unknown Source)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1398)
at processing.core.PApplet.handleMethods(PApplet.java:1593)
at processing.core.PApplet.handleMouseEvent(PApplet.java:2680)
at processing.core.PApplet.dequeueEvents(PApplet.java:2603)
at processing.core.PApplet.handleDraw(PApplet.java:2414)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1527)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
</code></pre>

<p>If it is something really basic I am missing, even throwing me a reference page address would be appreciated.</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Error to close the window with ControlP5</title>
      <link>https://forum.processing.org/two/discussion/13312/error-to-close-the-window-with-controlp5</link>
      <pubDate>Thu, 29 Oct 2015 16:47:20 +0000</pubDate>
      <dc:creator>Jose_Aparecido</dc:creator>
      <guid isPermaLink="false">13312@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys,</p>

<p>I open two windows using the buttons have controlP5 library, the first is a menu where calls this second window ...
I created a button in second window, instead of typing ESC, the same can press in the button to close the window.
When pressed the keys ESC, this code works normal, that is, closes the window and returns to the menu normally.
But however when chamos the same function as used in the ESC, with the button,  the following error occurs:</p>

<pre><code>java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 4
    at java.util.Vector.get(Unknown Source)
    at controlP5.ControllerList.get(Unknown Source)
    at controlP5.ControllerGroup.setMousePressed(Unknown Source)
    at controlP5.ControlWindow.mouseReleasedEvent(Unknown Source)
    at controlP5.ControlWindow.mouseEvent(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1236)
    at processing.core.PApplet.handleMethods(PApplet.java:1431)
    at processing.core.PApplet.handleMouseEvent(PApplet.java:2826)
    at processing.core.PApplet.dequeueEvents(PApplet.java:2725)
    at processing.core.PApplet.handleDraw(PApplet.java:2397)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
    at processing.core.PApplet.run(PApplet.java:2256)
    at java.lang.Thread.run(Unknown Source)
</code></pre>

<p>The second window was closed, but an error occurs in the first window, as if he could no longer run something ...
Any idea how to solve this?</p>

<p>Note: I will leave part of the code below, but it will not work, because it is only a part.</p>

<p>First Window ( Menu )</p>

<pre><code>static class Video02 extends PApplet {
  atualizaVar atualizaVarVideo02 = new atualizaVar(0,0);
  ControlP5 cp5_Video02; 

  int savedTimeVideo02, totalTimeVideo02 = 5000;
  float pontoAtuVideo02 = 0,
  int bar_sizeVideo02   = 15;
  int contBtn02         = 0;
  int menu02            = 1;
  int qtdeMenus02       = 1;
  int menuAtivo02       = 1;

  PVector v1_Video02;
  String[][] botoesMenu02;

  XML xml_Video02; //Variável para carregar arquivo XML
  ArrayList targetsVideo02 = new ArrayList();

  boolean retornaMenu = false;

  //Configurações Iniciais
  void setup(){
    size(displayWidth, displayHeight, JAVA2D); //Define tamanho da Janela, e forma de renderização
    background(255);             //Limpa tela
    smooth();                    //Suaviza serrilhado nos contornos do desenho
    textFont(utilVar.fontA, 40); //Define e de fonte e Tamanho
    fill(#1273C1);               //Seta cor para o Texto

    cp5_Video02 = new ControlP5(this); //Instancia objeto ControlP5 ( Biblioteca Gráfica )
    criaObjetosVideo02();

    utilVar.tempoAutClick = true;
    savedTimeVideo02      = millis();
    v1_Video02            = new PVector(0, 0);
    rob.mouseMove(30, height-100);

    cursor(HAND);
  }

  //Loop enquanto rodar o programa
  void draw(){

    background(255);
    textFont(utilVar.fontA, 40);
    fill(#1273C1);
    text("Escolha uma Opção para selecionar o Vídeo...", 70, 40);

    if (utilVar.tempoAutClick &amp;&amp; focused){
      if (Collections.disjoint(cp5_Video02.getMouseOverList(), targetsVideo02)==false) {
        if(cp5_Video02.getMouseOverList().size()==1) {
          controlP5.Controller controllerVideo02 = (controlP5.Controller)(cp5_Video02.getMouseOverList().get(0));

          String posicoes = controllerVideo02.getLabel().toString();
          String posBtnX  = posicoes.substring(0,4); 
          String posBtnY  = posicoes.substring(5,posicoes.length());

          desenhaBarraVideo02(int(posBtnX)-17, int(posBtnY)+150, 5, 150);
        }
      } else {
        savedTimeVideo02 = millis();
        pontoAtuVideo02  = 0;
      }
    } else {
      savedTimeVideo02 = millis();
      pontoAtuVideo02  = 0;
    }

    if (!utilVar.executando3 &amp;&amp; utilVar.usaLeapMotion){
      atualizaVarVideo02.atualizaLeap(utilVar.opcaoLeapMotion);
      rob.mouseMove(atualizaVarVideo02.xPos, atualizaVarVideo02.yPos);
    } else {
      atualizaVarVideo02.xPos = mouseX;
      atualizaVarVideo02.yPos = mouseY;
    }  
  }

  void mouseMoved(){   

  }

  void mousePressed(){
    utilVar.pressMouse3 = true;
  }

  void keyPressed() {
    if ( key == ESC ){
      retornaMenu();
      desabilitaDisp();
    }
 }

  void retornaMenu(){
    key = 0;
    this.stop();
    this.dispose();
    frame.hide();
    frame                = null;
    cp5_Video02          = null;
    atualizaVarVideo02   = null;
    utilVar.pressMouse3  = false;
    utilVar.executando2  = false;
    desabilitaDisp();
  }

  void desenhaBarraVideo02(int pW, int pH, int perc, int pontoMax){
    color c = color(0, 126, 255, 150);

    if (pontoAtuVideo02 &lt; pontoMax){
      pontoAtuVideo02 = pontoAtuVideo02 + utilVar.tempoAutClickMouse; //Conforme calibrar variával ( tempoAutClickMouse ), muda o tempo do Click automático
      fill (c);
      rect(pW, pH, bar_sizeVideo02, pontoAtuVideo02*-1 );
    } else { 
      pontoAtuVideo02 = 0;
      cliCkMouse();
      utilVar.pressMouse2 = true;
    }
  }

  void controlEvent(ControlEvent theControlEvent) {
    if (utilVar.pressMouse3){
      utilVar.opcaoLink = int(theControlEvent.controller().getValue());
      String nomeBotaoVideo02  = theControlEvent.controller().getName(); 

      if (nomeBotaoVideo02 == "btnProximoVideo02" || nomeBotaoVideo02 == "btnAnteriorVideo02" || nomeBotaoVideo02 == "btnVoltarVideo02"){
        if (nomeBotaoVideo02 == "btnProximoVideo02"){
          if (menuAtivo02 &lt; menu02){ 
            menuAtivo02++;
            habilitaDesabilitaMenu02(menuAtivo02);
          }  
        } else if (nomeBotaoVideo02 == "btnAnteriorVideo02"){
          if (menuAtivo02 &gt; 1){ 
            menuAtivo02--;
            habilitaDesabilitaMenu02(menuAtivo02);
          }
        } else if (nomeBotaoVideo02 == "btnVoltarVideo02"){ //Here is Called Idem press key ESC
          println("Volta 1");
          key = ESC;
          retornaMenu();
        } 
      } else {
        utilVar.imgPai      = int(theControlEvent.controller().getStringValue());
        utilVar.executando3 = true;    

        PApplet video03 = new Video03();  
        runSketch(new String[] { "***Vídeos***" }, video03);
      }  
    }
  }

  void criaObjetosVideo02(){
    xml_Video02 = loadXML(PATHIMGMENUVIDEOS + "/" + utilVar.idPessoa +"/pessoasMenuVideos.xml");
    XML[] children = xml_Video02.getChildren("menuVideo");

    botoesMenu02  = new String[children.length][2];

    for (int i = 0; i &lt; children.length; i++) {
      int idButton    = children[i].getInt("id");
      String idImagem = children[i].getString("id");
      int opcLink     = children[i].getInt("opcaoLink"); 
      String urlLink  = children[i].getString("linkURL");

      contBtn02++;    
      adicionaPosBtnXY(i, opcLink, contBtn02);
      //println("Path " + PATHIMGMENUVIDEOS + "/" + idPessoa + "/" + idImagem);
      cp5_Video02.addButton("btn"+nf(idButton,6))
                 .setId(idButton)
                 .setPosition(utilVar.posBtnX, utilVar.posBtnY)
                 .setImages(loadImage(PATHIMGMENUVIDEOS+"/"+utilVar.idPessoa+"/"+idImagem+"_0.jpg"), loadImage(PATHIMGMENUVIDEOS+"/"+utilVar.idPessoa+"/"+idImagem+"_1.jpg"), loadImage(PATHIMGMENUVIDEOS+"/"+utilVar.idPessoa+"/"+idImagem+"_2.jpg"))
                 .setStringValue(idImagem)
                 .setValue(opcLink)
                 .setLabel(nf(utilVar.posBtnX,4) + "," + nf(utilVar.posBtnY,4))
                 .setVisible(false)
                 .updateSize();

      targetsVideo02.add(cp5_Video02.getController("btn"+nf(idButton,6)));

      botoesMenu02[i][0] = "btn"+nf(idButton,6);
      botoesMenu02[i][1] = Integer.toString(menu02);

    }//for

    cp5_Video02.addButton("btnVoltarVideo02")
               .setPosition(2, 2)
               .setImages(loadImage(PATHDADOS + "/voltar0.png"), loadImage(PATHDADOS + "/voltar1.png"), loadImage(PATHDADOS + "/voltar2.png"))
               .updateSize();

    targetsVideo02.add(cp5_Video02.getController("btnVoltarVideo02"));

    habilitaDesabilitaMenu02(1);
  }

  void habilitaDesabilitaMenu02(int opcaoMnu){
    for (int i = 0; i &lt; botoesMenu02.length; i++) {
      cp5_Video02.getController(botoesMenu02[i][0]).setVisible((int(botoesMenu02[i][1]) == opcaoMnu));
    }
  }
}//função 
</code></pre>

<p>Only code execute on exit second window</p>

<pre><code>public static final class Video03 extends PApplet {
...

void keyPressed() {
    if ( key == ESC ){
      retornaMenu();
      desabilitaDisp();
    }
}

void controlEvent(ControlEvent theControlEvent) {
    if (utilVar.pressMouse3){
      String nomeBotao03  = theControlEvent.controller().getName(); 
      if (nomeBotao03 == "btnVoltarVideo03"){
        key = ESC;
        retornaMenu();
      }
    }

void retornaMenu(){
    //if (key == ESC ){
      key = 0;
      this.stop();
      this.dispose();
      frame.hide();
      frame               = null;
      //cp5_Video03         = null;
      atualizaVarVideo03  = null;
      utilVar.pressMouse2 = false;
      utilVar.pressMouse3 = false;
      utilVar.executando3 = false;
      desabilitaDisp();
    //}
  }
</code></pre>

<p>Summing up, the function retornaMenu() works on the ESC key, but not when triggered by controlP5, generating the error.
I hope I have managed to explain ...</p>

<p>Thanks for listening.</p>
]]></description>
   </item>
   </channel>
</rss>