Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How do I create a library

$
0
0

I am starting to learn Processing. I have lots of experience with procedural languages but not much with OO ones. I have a noobie question about building a Processing library. I know I'm missing something obvious but I'm missing it. Please point me in the right direction.

I followed the instructions at https://processing.org/tutorials/eclipse/ to load Processing into my Eclipse environment. I also followed the instructions at https://github.com/processing/processing-library-template to add the Processing Library Template to my Eclipse environment. This required resolving a problem with the ant version in my eclipse environment. I found the resolution here. (http://stackoverflow.com/questions/20702626/javac1-8-class-not-found ) I created a project in GitHub (https://github.com/grwoodsca/BindowsGaugesforProcessing) to provide version control of my library code. I got to step 4 in the Processing Library Template tutorial that says Congratulations, you are set and you can start writing your own Library by making changes to the source code in folder src. I imported the source files from gitHub into the src folder and modified the included .java file as follows:

/** * ##library.name## * ##library.sentence## * ##library.url## * * Copyright ##copyright## ##author## * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * * @author ##author## * @modified ##date## * @version ##library.prettyVersion## (##library.version##) */

package BindowsGaugesforProcessing.library;

import processing.core.*;

/** * This is a template class and can be used to start a new processing library or tool. * Make sure you rename this class as well as the name of the example package 'template' * to your own library or tool naming convention. * * (the tag example followed by the name of an example included in folder 'examples' will * automatically include the example in the javadoc.) * * @example xml_example */

public class BindowsGaugesforProcessing {

// myParent is a reference to the parent sketch
PApplet myParent;

int myVariable = 0;

public final static String VERSION = "##library.prettyVersion##";


/**
 * a Constructor, usually called in the setup() method in your sketch to
 * initialize and start the library.
 *
 * @example xml_example
 * @param theParent
 */
public BindowsGaugesforProcessing(PApplet theParent) {
    myParent = theParent;
    welcome();
    parent.registerMethod("dispose", this);
  }

  public void dispose() {
    // Anything in here will be called automatically when
    // the parent sketch shuts down. For instance, this might
    // shut down a thread used by this library.
  }
}


private void welcome() {
    System.out.println("##library.name## ##library.prettyVersion## by ##author##");
}

 /**
 * return the version of the library.
 *
 * @return String
 */
public static String version() {
    return VERSION;
}

}

However when I run the ant build it does not include my classes. What did I miss?


Viewing all articles
Browse latest Browse all 2896

Trending Articles