├── .classpath ├── .gitignore ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── README.md ├── data └── README ├── examples ├── BasicDrawing │ └── BasicDrawing.pde ├── README └── UsingTilt │ └── UsingTilt.pde ├── jpen-src └── jpen-code-321-trunk.zip ├── lib ├── jpen-2-3-64.dll ├── jpen-2-3.dll ├── jpen-2.jar ├── libjpen-2-3.jnilib ├── libjpen-2-4-x86_64.so └── libjpen-2-4.so ├── license.txt ├── resources ├── README.md ├── build.properties ├── build.xml ├── code │ ├── ExampleTaglet.class │ ├── ExampleTaglet.java │ ├── ant-contrib-1.0b3.jar │ └── doc.sh ├── library.properties └── stylesheet.css ├── src └── codeanticode │ └── tablet │ ├── Tablet.java │ ├── WindowPenClip.java │ └── WindowPenOwner.java └── web ├── index.html ├── logo.jpg └── stylesheet.css /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | */.DS_Store 3 | distribution 4 | bin 5 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tablet 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Tablet is a library for using pen tablets from Processing. Only tested with Wacom tablets so far. 2 | 3 | ACKNOWLEDGMENTS 4 | 5 | 1) JPen (Java Pen Tablet Access Library): 6 | https://github.com/nicarran/jpen 7 | 8 | 2) Processing Library Template: 9 | https://github.com/processing/processing-library-template 10 | 11 | 3) Simplified methods to access azimuth and altitude by Benedikt Gross: 12 | http://benedikt-gross.de/ 13 | -------------------------------------------------------------------------------- /data/README: -------------------------------------------------------------------------------- 1 | the data folder: 2 | If your library is using files like images, sound files, 3 | any data file, etc., put them into the data folder. 4 | When coding your library you can use processing's internal loading 5 | functions like loadImage(), loadStrings(), etc. to load files 6 | located inside the data folder into your library. 7 | 8 | -------------------------------------------------------------------------------- /examples/BasicDrawing/BasicDrawing.pde: -------------------------------------------------------------------------------- 1 | /** 2 | * Basic Drawing 3 | * by Andres Colubri. 4 | * 5 | * This program shows how to access position and pressure from the pen tablet. 6 | */ 7 | 8 | import codeanticode.tablet.*; 9 | 10 | Tablet tablet; 11 | 12 | void setup() { 13 | size(640, 480); 14 | 15 | tablet = new Tablet(this); 16 | 17 | background(0); 18 | stroke(255); 19 | } 20 | 21 | void draw() { 22 | // Instead of mousePressed, one can use the Tablet.isMovement() method, which 23 | // returns true when changes not only in position but also in pressure or tilt 24 | // are detected in the tablet. 25 | if (mousePressed) { 26 | strokeWeight(30 * tablet.getPressure()); 27 | 28 | // Aside from tablet.getPressure(), which should be available on all pens, 29 | // pen may support: 30 | //tablet.getTiltX(), tablet.getTiltY() MOST PENS 31 | //tablet.getSidePressure() - AIRBRUSH PEN 32 | //tablet.getRotation() - ART or PAINTING PEN 33 | 34 | // The tablet getPen methods can be used to retrieve the pen current and 35 | // saved position (requires calling tablet.saveState() at the end of 36 | // draw())... 37 | //line(tablet.getSavedPenX(), tablet.getSavedPenY(), tablet.getPenX(), tablet.getPenY()); 38 | 39 | // ...but it is equivalent to simply use Processing's built-in mouse 40 | // variables. 41 | line(pmouseX, pmouseY, mouseX, mouseY); 42 | } 43 | 44 | // The current values (pressure, tilt, etc.) can be saved using the saveState() method 45 | // and latter retrieved with getSavedxxx() methods: 46 | //tablet.saveState(); 47 | //tablet.getSavedPressure(); 48 | } -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | add examples for your library here. -------------------------------------------------------------------------------- /examples/UsingTilt/UsingTilt.pde: -------------------------------------------------------------------------------- 1 | /** 2 | * Basic Drawing 3 | * by Andres Colubri. 4 | * 5 | * This program shows how to use the tilt values from the pen. 6 | */ 7 | 8 | import codeanticode.tablet.*; 9 | 10 | Tablet tablet; 11 | 12 | void setup() { 13 | size(640, 480); 14 | 15 | tablet = new Tablet(this); 16 | 17 | background(0); 18 | stroke(200, 150); 19 | strokeWeight(2); 20 | } 21 | 22 | void draw() { 23 | if (0 < tablet.getPressure()) { 24 | float x = tablet.getTiltX(); 25 | float y = tablet.getTiltY(); 26 | line(mouseX, mouseY, mouseX + 20 * x, mouseY + 20 * y); 27 | } 28 | } -------------------------------------------------------------------------------- /jpen-src/jpen-code-321-trunk.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/jpen-src/jpen-code-321-trunk.zip -------------------------------------------------------------------------------- /lib/jpen-2-3-64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/lib/jpen-2-3-64.dll -------------------------------------------------------------------------------- /lib/jpen-2-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/lib/jpen-2-3.dll -------------------------------------------------------------------------------- /lib/jpen-2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/lib/jpen-2.jar -------------------------------------------------------------------------------- /lib/libjpen-2-3.jnilib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/lib/libjpen-2-3.jnilib -------------------------------------------------------------------------------- /lib/libjpen-2-4-x86_64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/lib/libjpen-2-4-x86_64.so -------------------------------------------------------------------------------- /lib/libjpen-2-4.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/lib/libjpen-2-4.so -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Tablet library 2 | 3 | Copyright (c) 2008-16 Andres Colubri 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General 16 | Public License along with this library; if not, write to the 17 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | 20 | -------------------------------------------------------------------------------- /resources/README.md: -------------------------------------------------------------------------------- 1 | ## How to install ##library.name## 2 | 3 | ### Install with the Contribution Manager 4 | 5 | Add contributed libraries by selecting the menu item _Sketch_ → _Import Library..._ → _Add Library..._ This will open the Contribution Manager, where you can browse for ##library.name##, or any other library you want to install. 6 | 7 | Not all available libraries have been converted to show up in this menu. If a library isn't there, it will need to be installed manually by following the instructions below. 8 | 9 | ### Manual Install 10 | 11 | Contributed libraries may be downloaded separately and manually placed within the `libraries` folder of your Processing sketchbook. To find (and change) the Processing sketchbook location on your computer, open the Preferences window from the Processing application (PDE) and look for the "Sketchbook location" item at the top. 12 | 13 | By default the following locations are used for your sketchbook folder: 14 | * For Mac users, the sketchbook folder is located inside `~/Documents/Processing` 15 | * For Windows users, the sketchbook folder is located inside `My Documents/Processing` 16 | 17 | Download ##library.name## from ##library.url## 18 | 19 | Unzip and copy the contributed library's folder into the `libraries` folder in the Processing sketchbook. You will need to create this `libraries` folder if it does not exist. 20 | 21 | The folder structure for library ##library.name## should be as follows: 22 | 23 | ``` 24 | Processing 25 | libraries 26 | ##library.name## 27 | examples 28 | library 29 | ##library.name##.jar 30 | reference 31 | src 32 | ``` 33 | 34 | Some folders like `examples` or `src` might be missing. After library ##library.name## has been successfully installed, restart the Processing application. 35 | 36 | ### Troubleshooting 37 | 38 | If you're having trouble, have a look at the [Processing Wiki](https://github.com/processing/processing/wiki/How-to-Install-a-Contributed-Library) for more information, or contact the author [##author.name##](##author.url##). 39 | -------------------------------------------------------------------------------- /resources/build.properties: -------------------------------------------------------------------------------- 1 | # Create libraries for the Processing open source programming language and 2 | # environment (http://www.processing.org) 3 | # 4 | # Customize the build properties to make the ant-build-process work for your 5 | # environment. How? Please read the comments below. 6 | # 7 | # The default properties are set for OS X. Please refer to comments for Windows 8 | # settings. 9 | 10 | 11 | # Where is your Processing sketchbook located? 12 | # If you are not sure, check the sketchbook location in your Processing 13 | # application preferences. 14 | # ${user.home} points the compiler to your home directory. 15 | # For windows the default path to your sketchbook would be 16 | # ${user.home}/My Documents/Processing (make adjustments below) 17 | 18 | sketchbook.location=${user.home}/Documents/Processing 19 | 20 | 21 | # Where are the jar files located that are required for compiling your library 22 | # such as e.g. core.jar? 23 | # By default the local classpath location points to folder libs inside Eclipse's 24 | # workspace (by default found in your home directory). 25 | # For Windows, the default path would be 26 | # ${user.home}/Documents/workspace/libs (make adjustments below) 27 | # For OS X,the following path will direct you into Processing's application 28 | # package, in case you put Processing inside your Applications folder. 29 | 30 | #classpath.local.location=${user.home}/Documents/workspace/libs 31 | classpath.local.location=/Applications/Processing.app/Contents/Java/core/library 32 | 33 | 34 | # Add all jar files that are required for compiling your project to the local 35 | # and project classpath. Use a comma as delimiter. These jar files must be 36 | # inside your classpath.local.location folder. 37 | 38 | classpath.local.include=core.jar jpen-2.jar jogl-all.jar gluegen-rt.jar 39 | 40 | 41 | # Add processing's libraries folder to the classpath. 42 | # If you don't need to include the libraries folder to your classpath, comment 43 | # out the following line. 44 | 45 | classpath.libraries.location=${sketchbook.location}/libraries 46 | 47 | 48 | # Set the java version that should be used to compile your library. 49 | 50 | java.target.version=1.7 51 | 52 | 53 | # Set the description of the Ant build.xml file. 54 | 55 | ant.description=Tablet Library Ant build file. 56 | 57 | 58 | # Give your library a name. The name must not contain spaces or special 59 | # characters. 60 | 61 | project.name=Tablet 62 | 63 | 64 | # The name as the user will see it. This can contain spaces and special 65 | # characters. 66 | 67 | project.prettyName=Tablet 68 | 69 | 70 | # Use 'normal' or 'fast' as value for project.compile. 71 | # 'fast' will only compile the project into your sketchbook. 72 | # 'normal' will compile the distribution including the javadoc-reference and all 73 | # web-files (the compile process here takes longer). 74 | # All files compiled with project.compile=normal are stored in the distribution 75 | # folder. 76 | 77 | project.compile=normal 78 | 79 | 80 | # Set your name and URL, used for the web page and properties file. 81 | 82 | author.name=Andres Colubri 83 | author.url=http://andrescolubri.net/ 84 | 85 | 86 | # Set the web page for your library. 87 | # This is NOT a direct link to where to download it. 88 | 89 | library.url=http://processing.andrescolubri.net/libraries/tablet/ 90 | 91 | 92 | # Set the category (or categories) of your library from the following list: 93 | # "3D" "Animation" "Compilations" "Data" 94 | # "Fabrication" "Geometry" "GUI" "Hardware" 95 | # "I/O" "Language" "Math" "Simulation" 96 | # "Sound" "Utilities" "Typography" "Video & Vision" 97 | # 98 | # If a value other than those listed is used, your library will listed as 99 | # "Other". Many categories must be comma-separated. 100 | 101 | library.categories=I/O 102 | 103 | 104 | # A short sentence (or fragment) to summarize the library's function. This will 105 | # be shown from inside the PDE when the library is being installed. Avoid 106 | # repeating the name of your library here. Also, avoid saying anything redundant 107 | # like mentioning that it's a library. This should start with a capitalized 108 | # letter, and end with a period. 109 | 110 | library.sentence=Tablet is a library for using pen tablets from Processing. 111 | 112 | 113 | # Additional information suitable for the Processing website. The value of 114 | # 'sentence' always will be prepended, so you should start by writing the 115 | # second sentence here. If your library only works on certain operating systems, 116 | # mention it here. 117 | 118 | library.paragraph= It provides simplified access to the pen's pressure, tilt, etc. It is based on JPen, the Java Pen Tablet Access Library. 119 | 120 | 121 | # Set the source code repository for your project. 122 | # Recommendations for storing your source code online are GitHub or Google Code. 123 | 124 | source.host=GitHub 125 | source.url=https://github.com/codeanticode/tablet 126 | source.repository=https://github.com/codeanticode/tablet.git 127 | 128 | 129 | # The current version of your library. 130 | # This number must be parsable as an int. It increments once with each release. 131 | # This is used to compare different versions of the same library, and check if 132 | # an update is available. 133 | 134 | library.version=8 135 | 136 | 137 | # The version as the user will see it. 138 | 139 | library.prettyVersion=2.0 140 | 141 | 142 | # The min and max revision of Processing compatible with your library. 143 | # Note that these fields use the revision and not the version of Processing, 144 | # parsable as an int. For example, the revision number for 2.2.1 is 227. 145 | # You can find the revision numbers in the change log: https://raw.githubusercontent.com/processing/processing/master/build/shared/revisions.txt 146 | # Only use maxRevision (or minRevision), when your library is known to 147 | # break in a later (or earlier) release. Otherwise, use the default value 0. 148 | 149 | compatible.minRevision=239 150 | compatible.maxRevision=0 151 | 152 | 153 | # The platforms and Processing version that the library has been tested 154 | # against. This information is only used in the generated webpage. 155 | 156 | tested.platform=osx,windows,linux 157 | tested.processingVersion=3.3 158 | 159 | 160 | # Additional information for the generated webpage. 161 | 162 | library.copyright=(c) 2008-17 163 | library.dependencies=jpen 164 | library.keywords=tablet, input, jpen 165 | 166 | 167 | # Include javadoc references into your project's javadocs. 168 | 169 | javadoc.java.href=http://docs.oracle.com/javase/7/docs/api/ 170 | javadoc.processing.href=http://processing.org/reference/javadoc/core/ 171 | -------------------------------------------------------------------------------- /resources/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ${ant.description} 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | ${line} 81 | Building the Processing library ${project.name} ${library.version} 82 | ${line} 83 | src path ${project.src} 84 | bin path ${project.bin} 85 | classpath.local ${classpath.local.location} 86 | sketchbook ${sketchbook.location} 87 | java version ${java.target.version} 88 | ${line} 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | ${exampleDir} 342 | 348 | 349 | 355 | 356 | 357 | 358 | 359 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | ${line} 378 | Name ${project.name} 379 | Version ${library.prettyVersion} (${library.version}) 380 | Compiled ${project.compile} 381 | Sketchbook ${sketchbook.location} 382 | ${line} 383 | done, finished. 384 | ${line} 385 | 386 | 387 | 388 | 389 | 390 | -------------------------------------------------------------------------------- /resources/code/ExampleTaglet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/resources/code/ExampleTaglet.class -------------------------------------------------------------------------------- /resources/code/ExampleTaglet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * -Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * -Redistribution in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * Neither the name of Sun Microsystems, Inc. or the names of 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * This software is provided "AS IS," without a warranty of any 21 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND 22 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY 24 | * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY 25 | * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR 26 | * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR 27 | * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE 28 | * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, 29 | * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER 30 | * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF 31 | * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN 32 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 33 | * 34 | * You acknowledge that Software is not designed, licensed or 35 | * intended for use in the design, construction, operation or 36 | * maintenance of any nuclear facility. 37 | */ 38 | 39 | import com.sun.tools.doclets.Taglet; 40 | import com.sun.javadoc.*; 41 | import java.util.Map; 42 | import java.io.*; 43 | /** 44 | * A sample Taglet representing @example. This tag can be used in any kind of 45 | * {@link com.sun.javadoc.Doc}. It is not an inline tag. The text is displayed 46 | * in yellow to remind the developer to perform a task. For 47 | * example, "@example Hello" would be shown as: 48 | *
49 | *
50 | * To Do: 51 | *
Fix this! 52 | *
53 | *
54 | * 55 | * @author Jamie Ho 56 | * @since 1.4 57 | */ 58 | 59 | public class ExampleTaglet implements Taglet { 60 | 61 | private static final String NAME = "example"; 62 | private static final String HEADER = "example To Do:"; 63 | 64 | /** 65 | * Return the name of this custom tag. 66 | */ 67 | public String getName() { 68 | return NAME; 69 | } 70 | 71 | /** 72 | * Will return true since @example 73 | * can be used in field documentation. 74 | * @return true since @example 75 | * can be used in field documentation and false 76 | * otherwise. 77 | */ 78 | public boolean inField() { 79 | return true; 80 | } 81 | 82 | /** 83 | * Will return true since @example 84 | * can be used in constructor documentation. 85 | * @return true since @example 86 | * can be used in constructor documentation and false 87 | * otherwise. 88 | */ 89 | public boolean inConstructor() { 90 | return true; 91 | } 92 | 93 | /** 94 | * Will return true since @example 95 | * can be used in method documentation. 96 | * @return true since @example 97 | * can be used in method documentation and false 98 | * otherwise. 99 | */ 100 | public boolean inMethod() { 101 | return true; 102 | } 103 | 104 | /** 105 | * Will return true since @example 106 | * can be used in method documentation. 107 | * @return true since @example 108 | * can be used in overview documentation and false 109 | * otherwise. 110 | */ 111 | public boolean inOverview() { 112 | return true; 113 | } 114 | 115 | /** 116 | * Will return true since @example 117 | * can be used in package documentation. 118 | * @return true since @example 119 | * can be used in package documentation and false 120 | * otherwise. 121 | */ 122 | public boolean inPackage() { 123 | return true; 124 | } 125 | 126 | /** 127 | * Will return true since @example 128 | * can be used in type documentation (classes or interfaces). 129 | * @return true since @example 130 | * can be used in type documentation and false 131 | * otherwise. 132 | */ 133 | public boolean inType() { 134 | return true; 135 | } 136 | 137 | /** 138 | * Will return false since @example 139 | * is not an inline tag. 140 | * @return false since @example 141 | * is not an inline tag. 142 | */ 143 | 144 | public boolean isInlineTag() { 145 | return false; 146 | } 147 | 148 | /** 149 | * Register this Taglet. 150 | * @param tagletMap the map to register this tag to. 151 | */ 152 | public static void register(Map tagletMap) { 153 | ExampleTaglet tag = new ExampleTaglet(); 154 | Taglet t = (Taglet) tagletMap.get(tag.getName()); 155 | if (t != null) { 156 | tagletMap.remove(tag.getName()); 157 | } 158 | tagletMap.put(tag.getName(), tag); 159 | } 160 | 161 | /** 162 | * Given the Tag representation of this custom 163 | * tag, return its string representation. 164 | * @param tag the Tag representation of this custom tag. 165 | */ 166 | public String toString(Tag tag) { 167 | return createHTML(readFile(tag.text())); 168 | } 169 | 170 | 171 | /** 172 | * Given an array of Tags representing this custom 173 | * tag, return its string representation. 174 | * @param tags the array of Tags representing of this custom tag. 175 | */ 176 | public String toString(Tag[] tags) { 177 | if (tags.length == 0) { 178 | return null; 179 | } 180 | return createHTML(readFile(tags[0].text())); 181 | } 182 | 183 | 184 | 185 | String createHTML(String theString) { 186 | if(theString!=null) { 187 | String dd = ""; 193 | 194 | return dd+"\n
" + 195 | "
+Example
" + 196 | "
"+theString+"
" + 197 | "
"; 198 | } 199 | return ""; 200 | } 201 | 202 | 203 | /** 204 | * check if the examples directory exists and return the example as given in the tag. 205 | * @param theExample the name of the example 206 | */ 207 | String readFile(String theExample) { 208 | String record = ""; 209 | String myResult = ""; 210 | int recCount = 0; 211 | String myDir = "../examples"; 212 | File file=new File(myDir); 213 | if(file.exists()==false) { 214 | myDir = "./examples"; 215 | } 216 | try { 217 | FileReader fr = new FileReader(myDir+"/"+theExample+"/"+theExample+".pde"); 218 | BufferedReader br = new BufferedReader(fr); 219 | record = new String(); 220 | while ((record = br.readLine()) != null) { 221 | myResult += record+"\n"; 222 | } 223 | } catch (IOException e) { 224 | System.out.println(e); 225 | return null; 226 | } 227 | return myResult; 228 | } 229 | } 230 | 231 | 232 | -------------------------------------------------------------------------------- /resources/code/ant-contrib-1.0b3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/resources/code/ant-contrib-1.0b3.jar -------------------------------------------------------------------------------- /resources/code/doc.sh: -------------------------------------------------------------------------------- 1 | # a shell script to create a java documentation 2 | # for a processing library. 3 | # 4 | # make changes to the variables below so they 5 | # fit the structure of your library 6 | 7 | # the package name of your library 8 | package=template; 9 | 10 | # source folder location 11 | src=../src; 12 | 13 | # the destination folder of your documentation 14 | dest=../documentation; 15 | 16 | 17 | # compile the java documentation 18 | javadoc -d $dest -stylesheetfile ./stylesheet.css -sourcepath ${src} ${package} 19 | -------------------------------------------------------------------------------- /resources/library.properties: -------------------------------------------------------------------------------- 1 | # More on this file here: https://github.com/processing/processing/wiki/Library-Basics 2 | # UTF-8 supported. 3 | 4 | # The name of your library as you want it formatted. 5 | name = ##library.name## 6 | 7 | # List of authors. Links can be provided using the syntax [author name](url). 8 | authors = [##author.name##](##author.url##) 9 | 10 | # A web page for your library, NOT a direct link to where to download it. 11 | url = ##library.url## 12 | 13 | # The category (or categories) of your library, must be from the following list: 14 | # "3D" "Animation" "Compilations" "Data" 15 | # "Fabrication" "Geometry" "GUI" "Hardware" 16 | # "I/O" "Language" "Math" "Simulation" 17 | # "Sound" "Utilities" "Typography" "Video & Vision" 18 | # 19 | # If a value other than those listed is used, your library will listed as 20 | # "Other". Many categories must be comma-separated. 21 | categories = ##library.categories## 22 | 23 | # A short sentence (or fragment) to summarize the library's function. This will 24 | # be shown from inside the PDE when the library is being installed. Avoid 25 | # repeating the name of your library here. Also, avoid saying anything redundant 26 | # like mentioning that it's a library. This should start with a capitalized 27 | # letter, and end with a period. 28 | sentence = ##library.sentence## 29 | 30 | # Additional information suitable for the Processing website. The value of 31 | # 'sentence' always will be prepended, so you should start by writing the 32 | # second sentence here. If your library only works on certain operating systems, 33 | # mention it here. 34 | paragraph = ##library.paragraph## 35 | 36 | # Links in the 'sentence' and 'paragraph' attributes can be inserted using the 37 | # same syntax as for authors. 38 | # That is, [here is a link to Processing](http://processing.org/) 39 | 40 | # A version number that increments once with each release. This is used to 41 | # compare different versions of the same library, and check if an update is 42 | # available. You should think of it as a counter, counting the total number of 43 | # releases you've had. 44 | version = ##library.version## # This must be parsable as an int 45 | 46 | # The version as the user will see it. If blank, the version attribute will be 47 | # used here. This should be a single word, with no spaces. 48 | prettyVersion = ##library.prettyVersion## # This is treated as a String 49 | 50 | # The min and max revision of Processing compatible with your library. 51 | # Note that these fields use the revision and not the version of Processing, 52 | # parsable as an int. For example, the revision number for 2.2.1 is 227. 53 | # You can find the revision numbers in the change log: https://raw.githubusercontent.com/processing/processing/master/build/shared/revisions.txt 54 | # Only use maxRevision (or minRevision), when your library is known to 55 | # break in a later (or earlier) release. Otherwise, use the default value 0. 56 | minRevision = ##compatible.minRevision## 57 | maxRevision = ##compatible.maxRevision## 58 | -------------------------------------------------------------------------------- /resources/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | /* Define colors, fonts and other style attributes here to override the defaults */ 3 | /* processingLibs style by andreas schlegel, sojamo */ 4 | 5 | 6 | body { 7 | margin : 0; 8 | padding : 0; 9 | padding-left : 10px; 10 | padding-right : 8px; 11 | background-color : #FFFFFF; 12 | font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 13 | font-size : 100%; 14 | font-size : 0.7em; 15 | font-weight : normal; 16 | line-height : normal; 17 | margin-bottom:30px; 18 | } 19 | 20 | 21 | 22 | 23 | /* Headings */ 24 | h1, h2, h3, h4, h5, th { 25 | font-family :Arial, Helvetica, sans-serif; 26 | font-size:1.2em; 27 | } 28 | 29 | 30 | p { 31 | font-size : 1em; 32 | width:80%; 33 | } 34 | 35 | pre, code { 36 | font-family : "Courier New", Courier, monospace; 37 | font-size : 12px; 38 | line-height : normal; 39 | } 40 | 41 | 42 | 43 | table { 44 | border:0; 45 | margin-bottom:10px; 46 | margin-top:10px; 47 | } 48 | 49 | 50 | tr, td { 51 | border-top: 0px solid; 52 | border-left: 0px solid; 53 | padding-top:8px; 54 | padding-bottom:8px; 55 | } 56 | 57 | 58 | 59 | hr { 60 | border:0; 61 | height:1px; 62 | padding:0; 63 | margin:0; 64 | margin-bottom:4px; 65 | 66 | } 67 | 68 | 69 | 70 | dd, th, td, font { 71 | font-size:1.0em; 72 | line-height:1.0em; 73 | } 74 | 75 | 76 | 77 | dt { 78 | margin-bottom:0px; 79 | } 80 | 81 | 82 | 83 | dd { 84 | margin-top:2px; 85 | margin-bottom:4px; 86 | } 87 | 88 | 89 | 90 | a { 91 | text-decoration: underline; 92 | font-weight: normal; 93 | } 94 | 95 | a:hover, 96 | a:active { 97 | text-decoration: underline; 98 | font-weight: normal; 99 | } 100 | 101 | a:visited, 102 | a:link:visited { 103 | text-decoration: underline; 104 | font-weight: normal; 105 | } 106 | 107 | 108 | img { 109 | border: 0px solid #000000; 110 | } 111 | 112 | 113 | 114 | /* Navigation bar fonts */ 115 | .NavBarCell1 { 116 | border:0; 117 | } 118 | 119 | .NavBarCell1Rev { 120 | border:0; 121 | } 122 | 123 | .NavBarFont1 { 124 | font-family: Arial, Helvetica, sans-serif; 125 | font-size:1.1em; 126 | } 127 | 128 | 129 | .NavBarFont1 b { 130 | font-weight:normal; 131 | } 132 | 133 | 134 | 135 | .NavBarFont1:after, .NavBarFont1Rev:after { 136 | font-weight:normal; 137 | content: " \\"; 138 | } 139 | 140 | 141 | .NavBarFont1Rev { 142 | font-family: Arial, Helvetica, sans-serif; 143 | font-size:1.1em; 144 | } 145 | 146 | .NavBarFont1Rev b { 147 | font-family: Arial, Helvetica, sans-serif; 148 | font-size:1.1em; 149 | font-weight:normal; 150 | } 151 | 152 | .NavBarCell2 { 153 | font-family: Arial, Helvetica, sans-serif; 154 | } 155 | 156 | .NavBarCell3 { 157 | font-family: Arial, Helvetica, sans-serif; 158 | } 159 | 160 | 161 | 162 | font.FrameItemFont { 163 | font-family: Helvetica, Arial, sans-serif; 164 | font-size:1.1em; 165 | line-height:1.1em; 166 | } 167 | 168 | font.FrameHeadingFont { 169 | font-family: Helvetica, Arial, sans-serif; 170 | line-height:32px; 171 | } 172 | 173 | /* Font used in left-hand frame lists */ 174 | .FrameTitleFont { 175 | font-family: Helvetica, Arial, sans-serif 176 | } 177 | 178 | 179 | .toggleList { 180 | padding:0; 181 | margin:0; 182 | margin-top:12px; 183 | } 184 | 185 | .toggleList dt { 186 | font-weight:bold; 187 | font-size:12px; 188 | font-family:arial,sans-serif; 189 | padding:0px; 190 | margin:10px 0px 10px 0px; 191 | } 192 | 193 | .toggleList dt span { 194 | font-family: monospace; 195 | padding:0; 196 | margin:0; 197 | } 198 | 199 | 200 | .toggleList dd { 201 | margin:0; 202 | padding:0; 203 | } 204 | 205 | html.isjs .toggleList dd { 206 | display: none; 207 | } 208 | 209 | .toggleList pre { 210 | padding: 4px 4px 4px 4px; 211 | } 212 | 213 | 214 | 215 | 216 | 217 | /* COLORS */ 218 | 219 | pre, code { 220 | color: #000000; 221 | } 222 | 223 | 224 | body { 225 | color : #333333; 226 | background-color :#FFFFFF; 227 | } 228 | 229 | 230 | h1, h2, h3, h4, h5, h6 { 231 | color:#555; 232 | } 233 | 234 | a, 235 | .toggleList dt { 236 | color: #1a7eb0; 237 | } 238 | 239 | a:hover, 240 | a:active { 241 | color: #1a7eb0; 242 | } 243 | 244 | a:visited, 245 | a:link:visited { 246 | color: #1a7eb0; 247 | } 248 | 249 | td,tr { 250 | border-color: #999999; 251 | } 252 | 253 | hr { 254 | color:#999999; 255 | background:#999999; 256 | } 257 | 258 | 259 | .TableHeadingColor { 260 | background: #dcdcdc; 261 | color: #555; 262 | } 263 | 264 | 265 | .TableSubHeadingColor { 266 | background: #EEEEFF 267 | } 268 | 269 | .TableRowColor { 270 | background: #FFFFFF 271 | } 272 | 273 | 274 | .NavBarCell1 { 275 | background-color:#dcdcdc; 276 | color:#000; 277 | } 278 | 279 | .NavBarCell1 a { 280 | color:#333; 281 | } 282 | 283 | 284 | .NavBarCell1Rev { 285 | background-color:transparent; 286 | } 287 | 288 | .NavBarFont1 { 289 | color:#333; 290 | } 291 | 292 | 293 | .NavBarFont1Rev { 294 | color:#fff; 295 | } 296 | 297 | .NavBarCell2 { 298 | background-color:#999; 299 | } 300 | 301 | .NavBarCell2 a { 302 | color:#fff; 303 | } 304 | 305 | 306 | 307 | .NavBarCell3 { 308 | background-color:#dcdcdc; 309 | } 310 | 311 | -------------------------------------------------------------------------------- /src/codeanticode/tablet/Tablet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ##library.name## 3 | * ##library.sentence## 4 | * ##library.url## 5 | * 6 | * Copyright ##copyright## ##author## 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General 19 | * Public License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 21 | * Boston, MA 02111-1307 USA 22 | * 23 | * @author ##author## 24 | * @modified ##date## 25 | * @version ##library.prettyVersion## (##library.version##) 26 | */ 27 | 28 | package codeanticode.tablet; 29 | 30 | import processing.awt.PGraphicsJava2D; 31 | import processing.core.*; 32 | import processing.javafx.PGraphicsFX2D; 33 | //import processing.opengl.PGL; 34 | import processing.opengl.PGraphicsOpenGL; 35 | //import processing.opengl.PSurfaceJOGL; 36 | import jpen.event.*; 37 | import jpen.owner.multiAwt.AwtPenToolkit; 38 | import jpen.*; 39 | 40 | import java.awt.Canvas; 41 | import java.lang.reflect.*; 42 | 43 | import com.jogamp.newt.event.WindowAdapter; 44 | import com.jogamp.newt.event.WindowEvent; 45 | import com.jogamp.newt.opengl.GLWindow; 46 | 47 | /** 48 | * 49 | * This class extends the PenListener class of the JPen library by adding getter 50 | * methods to retrieve the pen values (position, pressure, tilt, pressed 51 | * buttons, etc.). It also defines event methods that are called inside the 52 | * Processing sketch when tablet events such as pressure or position changes 53 | * occur. These methods are penButtonEventMethod, penKindEventMethod, 54 | * penLevelEventMethod and penScrollEventMethod, and always pass as parameter 55 | * the Tablet object generating the event:
56 | *
57 | * void penLevelEventMethod(Tablet tablet) {
58 | *   println(tablet.getPressure());
59 | * }

60 | *
61 | * However, these methods don't need to be implemented.
62 | *
63 | * For more details about the JPen library, check the JPen website. 65 | * 66 | * @author Andres Colubri 67 | * 68 | */ 69 | public class Tablet implements PenListener { 70 | public final static String VERSION = "##library.prettyVersion##"; 71 | 72 | /** 73 | * Constant to identify an unknown pen kind. 74 | */ 75 | public static final int UNDEFINED = 0; 76 | /** 77 | * Constant to identify the mouse. 78 | */ 79 | public static final int CURSOR = 1; 80 | /** 81 | * Constant to identify the drawing tip of the pen. 82 | */ 83 | public static final int STYLUS = 2; 84 | /** 85 | * Constant to identify the erasing tip of the pen. 86 | */ 87 | public static final int ERASER = 3; 88 | 89 | protected PApplet parent; 90 | protected PenManager pm; 91 | 92 | 93 | protected Method penButtonEventMethod; 94 | protected Method penKindEventMethod; 95 | protected Method penLevelEventMethod; 96 | protected Method penScrollEventMethod; 97 | 98 | protected boolean isMovementEvent; 99 | 100 | protected boolean saveState; 101 | final protected PenStateCopy savedPen; 102 | 103 | /** 104 | * The class constructor that takes the parent Processing applet as parameter 105 | * to initialize the pen manager. 106 | * 107 | * @param parent 108 | * PApplet 109 | */ 110 | public Tablet(PApplet parent) { 111 | this.parent = parent; 112 | 113 | welcome(); 114 | 115 | PSurface surf = parent.getSurface(); 116 | if (parent.g instanceof PGraphicsOpenGL) { 117 | // Using parent with an OpenGL renderer results in no tablet events being 118 | // detected, so will try to get the AWT canvas associated to the GL 119 | // surface, if any. 120 | GLWindow win = (GLWindow)surf.getNative(); 121 | win.addWindowListener(new WindowAdapter() { 122 | @Override 123 | public void windowDestroyNotify(WindowEvent ev) { 124 | synchronized(Tablet.class) { 125 | Tablet.class.notify(); 126 | } 127 | } 128 | }); 129 | pm = new PenManager(new WindowPenOwner(win)); 130 | pm.pen.addListener(this); 131 | 132 | // try { 133 | // Tablet.class.wait(); 134 | // } catch (InterruptedException e) { 135 | // e.printStackTrace(); 136 | // } 137 | 138 | } else if (parent.g instanceof PGraphicsFX2D) { 139 | throw new RuntimeException("The JavaFX renderer is not supported by the Tablet library"); 140 | // AwtPenToolkit.addPenListener(parent, this); 141 | } else if (parent.g instanceof PGraphicsJava2D) { 142 | Canvas canvas = (Canvas)surf.getNative(); 143 | AwtPenToolkit.addPenListener(canvas, this); 144 | pm = AwtPenToolkit.getPenManager(); 145 | } 146 | savedPen = new PenStateCopy(); 147 | 148 | // Disable event buffering 149 | pm.pen.setFrequencyLater(1001); 150 | 151 | try { 152 | penButtonEventMethod = parent.getClass().getMethod("penButtonEvent", 153 | new Class[] { Tablet.class }); 154 | } catch (Exception e) { 155 | // no such method, or an error.. which is fine, just ignore 156 | } 157 | 158 | try { 159 | penKindEventMethod = parent.getClass().getMethod("penKindEvent", 160 | new Class[] { Tablet.class }); 161 | } catch (Exception e) { 162 | // no such method, or an error.. which is fine, just ignore 163 | } 164 | 165 | try { 166 | penLevelEventMethod = parent.getClass().getMethod("penLevelEvent", 167 | new Class[] { Tablet.class }); 168 | } catch (Exception e) { 169 | // no such method, or an error.. which is fine, just ignore 170 | } 171 | 172 | try { 173 | penScrollEventMethod = parent.getClass().getMethod("penScrollEvent", 174 | new Class[] { Tablet.class }); 175 | } catch (Exception e) { 176 | // no such method, or an error.. which is fine, just ignore 177 | } 178 | } 179 | 180 | /** 181 | * Returns the current pressure. 182 | * 183 | * @return float 184 | */ 185 | public float getPressure() { 186 | return pm.pen.getLevelValue(PLevel.Type.PRESSURE); 187 | } 188 | 189 | /** 190 | * Returns the current X position of the pen. 191 | * 192 | * @return float 193 | */ 194 | public float getPenX() { 195 | return pm.pen.getLevelValue(PLevel.Type.X); 196 | } 197 | 198 | /** 199 | * Returns the current Y position of the pen. 200 | * 201 | * @return float 202 | */ 203 | public float getPenY() { 204 | return pm.pen.getLevelValue(PLevel.Type.Y); 205 | } 206 | 207 | /** 208 | * Returns the current X tilt of the pen. 209 | * 210 | * @return float 211 | */ 212 | public float getTiltX() { 213 | return pm.pen.getLevelValue(PLevel.Type.TILT_X); 214 | } 215 | 216 | /** 217 | * Returns the current Y tilt of the pen. 218 | * 219 | * @return float 220 | */ 221 | public float getTiltY() { 222 | return pm.pen.getLevelValue(PLevel.Type.TILT_Y); 223 | } 224 | 225 | /** 226 | * Barrel button or wheel. Range: 0 to 1 towards the pen tip. 227 | * 228 | * @return float 229 | */ 230 | public float getSidePressure() { 231 | return pm.pen.getLevelValue(PLevel.Type.SIDE_PRESSURE); 232 | } 233 | 234 | /** 235 | * Returns pen rotation. Range: 0 to 2 * PI clockwise. 236 | * 237 | * @return float 238 | */ 239 | public float getRotation() { 240 | return pm.pen.getLevelValue(PLevel.Type.ROTATION); 241 | } 242 | 243 | /** 244 | * Returns the current x azimuth of the pen. 245 | * 246 | * @return float 247 | */ 248 | public float getAzimuth() { 249 | double tiltX = getTiltX(); 250 | double tiltY = getTiltY(); 251 | 252 | double[] out = new double[2]; 253 | PLevel.Type.evalAzimuthXAndAltitude(out, tiltX, tiltY); 254 | return (float) out[0]; 255 | } 256 | 257 | /** 258 | * Returns the current altitude of the pen. 259 | * 260 | * @return float 261 | */ 262 | public float getAltitude() { 263 | double tiltX = getTiltX(); 264 | double tiltY = getTiltY(); 265 | 266 | double[] out = new double[2]; 267 | PLevel.Type.evalAzimuthXAndAltitude(out, tiltX, tiltY); 268 | return (float) out[1]; 269 | } 270 | 271 | /** 272 | * Calculates the current x azimuth and altitude values and return them in the 273 | * azimuthXAndAltitude array. 274 | * 275 | * @param azimuthXAndAltitude 276 | * float[] 277 | */ 278 | public void getAzimuthXAndAltitude(float[] azimuthXAndAltitude) { 279 | if ((azimuthXAndAltitude == null) || azimuthXAndAltitude.length != 2) 280 | return; 281 | double tiltX = getTiltX(); 282 | double tiltY = getTiltY(); 283 | 284 | double[] out = new double[2]; 285 | PLevel.Type.evalAzimuthXAndAltitude(out, tiltX, tiltY); 286 | azimuthXAndAltitude[0] = (float) out[0]; 287 | azimuthXAndAltitude[1] = (float) out[1]; 288 | } 289 | 290 | /** 291 | * Returns true if a level event has occurred, meaning that a change in 292 | * pressure, position or tilt has been detected. 293 | * 294 | * @return boolean 295 | */ 296 | public boolean isMovement() { 297 | return isMovementEvent; 298 | } 299 | 300 | /** 301 | * Returns the current pen kind: CURSOR is the mouse, STYLUS is the drawing 302 | * tip of the pen and ERASER is the eraser tip of the pen. 303 | * 304 | * @return int 305 | */ 306 | public int getPenKind() { 307 | if (pm.pen.getKind() == PKind.valueOf(PKind.Type.CURSOR)) 308 | return CURSOR; 309 | else if (pm.pen.getKind() == PKind.valueOf(PKind.Type.STYLUS)) 310 | return STYLUS; 311 | else if (pm.pen.getKind() == PKind.valueOf(PKind.Type.ERASER)) 312 | return ERASER; 313 | else 314 | return UNDEFINED; 315 | } 316 | 317 | /** 318 | * Returns true if there is any button being currently pressed. 319 | * 320 | * @return boolean 321 | */ 322 | public boolean isDown() { 323 | return pm.pen.hasPressedButtons(); 324 | } 325 | 326 | /** 327 | * Returns true if there is the center button is currently pressed. 328 | * 329 | * @return boolean 330 | */ 331 | public boolean isCenterDown() { 332 | return pm.pen.getButtonValue(PButton.Type.CENTER); 333 | } 334 | 335 | /** 336 | * Returns true if there is the left button is currently pressed. 337 | * 338 | * @return boolean 339 | */ 340 | public boolean isLeftDown() { 341 | return pm.pen.getButtonValue(PButton.Type.LEFT); 342 | } 343 | 344 | /** 345 | * Returns true if there is the right button is currently pressed. When using 346 | * the stylus, pressing it agains the tablet surface is considered as a right 347 | * button click. 348 | * 349 | * @return boolean 350 | */ 351 | public boolean isRightDown() { 352 | return pm.pen.getButtonValue(PButton.Type.RIGHT); 353 | } 354 | 355 | /** 356 | * Saves the current state of the pen. 357 | */ 358 | public void saveState() { 359 | savedPen.setValues(pm.pen); 360 | } 361 | 362 | /** 363 | * Returns the saved pressure. 364 | * 365 | * @return float 366 | */ 367 | public float getSavedPressure() { 368 | return savedPen.getLevelValue(PLevel.Type.PRESSURE); 369 | } 370 | 371 | /** 372 | * Returns the saved X position of the pen. 373 | * 374 | * @return float 375 | */ 376 | public float getSavedPenX() { 377 | return savedPen.getLevelValue(PLevel.Type.X); 378 | } 379 | 380 | /** 381 | * Returns the saved Y position of the pen. 382 | * 383 | * @return float 384 | */ 385 | public float getSavedPenY() { 386 | return savedPen.getLevelValue(PLevel.Type.Y); 387 | } 388 | 389 | /** 390 | * Returns the saved X tilt of the pen. 391 | * 392 | * @return float 393 | */ 394 | public float getSavedTiltX() { 395 | return savedPen.getLevelValue(PLevel.Type.TILT_X); 396 | } 397 | 398 | /** 399 | * Returns the saved side pressure. 400 | * 401 | * @return float 402 | */ 403 | public float getSavedSidePressure() { 404 | return pm.pen.getLevelValue(PLevel.Type.SIDE_PRESSURE); 405 | } 406 | 407 | /** 408 | * Returns the saved rotation. 409 | * 410 | * @return float 411 | */ 412 | public float getSavedRotation() { 413 | return pm.pen.getLevelValue(PLevel.Type.ROTATION); 414 | } 415 | 416 | /** 417 | * Returns the saved Y tilt of the pen. 418 | * 419 | * @return float 420 | */ 421 | public float getSavedTiltY() { 422 | return savedPen.getLevelValue(PLevel.Type.TILT_Y); 423 | } 424 | 425 | /** 426 | * Returns the saved x azimuth of the pen. 427 | * 428 | * @return float 429 | */ 430 | public float getSavedAzimuth() { 431 | double tiltX = getSavedTiltX(); 432 | double tiltY = getSavedTiltY(); 433 | 434 | double[] out = new double[2]; 435 | PLevel.Type.evalAzimuthXAndAltitude(out, tiltX, tiltY); 436 | return (float) out[0]; 437 | } 438 | 439 | /** 440 | * Returns the saved altitude of the pen. 441 | * 442 | * @return float 443 | */ 444 | public float getSavedAltitude() { 445 | double tiltX = getSavedTiltX(); 446 | double tiltY = getSavedTiltY(); 447 | 448 | double[] out = new double[2]; 449 | PLevel.Type.evalAzimuthXAndAltitude(out, tiltX, tiltY); 450 | return (float) out[1]; 451 | } 452 | 453 | /** 454 | * Calculates the x azimuth and altitude values using the saved tablet state 455 | * and return them in the azimuthXAndAltitude array. 456 | * 457 | * @param azimuthXAndAltitude 458 | * float[] 459 | */ 460 | public void getSavedAzimuthXAndAltitude(float[] azimuthXAndAltitude) { 461 | if ((azimuthXAndAltitude == null) || azimuthXAndAltitude.length != 2) 462 | return; 463 | double tiltX = getSavedTiltX(); 464 | double tiltY = getSavedTiltY(); 465 | 466 | double[] out = new double[2]; 467 | PLevel.Type.evalAzimuthXAndAltitude(out, tiltX, tiltY); 468 | azimuthXAndAltitude[0] = (float) out[0]; 469 | azimuthXAndAltitude[1] = (float) out[1]; 470 | } 471 | 472 | /** 473 | * Invokes penButtonEventMethod in the Processing applet (if exists) when a 474 | * button event occurs. 475 | * 476 | * @param ev 477 | * PButtonEvent 478 | */ 479 | public void penButtonEvent(PButtonEvent ev) { 480 | if (penButtonEventMethod != null) { 481 | try { 482 | penButtonEventMethod.invoke(parent, new Object[] { this }); 483 | } catch (Exception e) { 484 | System.err.println("error, disabling penButtonEvent()"); 485 | e.printStackTrace(); 486 | penButtonEventMethod = null; 487 | } 488 | } 489 | } 490 | 491 | /** 492 | * Invokes penKindEventMethod in the Processing applet (if exists) when a kind 493 | * event occurs. 494 | * 495 | * @param ev 496 | * PKindEvent 497 | */ 498 | public void penKindEvent(PKindEvent ev) { 499 | if (penKindEventMethod != null) { 500 | try { 501 | penKindEventMethod.invoke(parent, new Object[] { this }); 502 | } catch (Exception e) { 503 | System.err.println("error, disabling penKindEvent()"); 504 | e.printStackTrace(); 505 | penKindEventMethod = null; 506 | } 507 | } 508 | } 509 | 510 | /** 511 | * Invokes penLevelEventMethod in the Processing applet (if exists) when a 512 | * level event occurs. 513 | * 514 | * @param ev 515 | * PLevelEvent 516 | */ 517 | public void penLevelEvent(PLevelEvent ev) { 518 | isMovementEvent = ev.isMovement(); 519 | 520 | if (penLevelEventMethod != null) { 521 | try { 522 | penLevelEventMethod.invoke(parent, new Object[] { this }); 523 | } catch (Exception e) { 524 | System.err.println("error, disabling penLevelEvent()"); 525 | e.printStackTrace(); 526 | penLevelEventMethod = null; 527 | } 528 | } 529 | } 530 | 531 | /** 532 | * Invokes penScrollEventMethod in the Processing applet (if exists) when a 533 | * scroll event occurs. 534 | * 535 | * @param ev 536 | * PScrollEvent 537 | */ 538 | public void penScrollEvent(PScrollEvent ev) { 539 | if (penScrollEventMethod != null) { 540 | try { 541 | penScrollEventMethod.invoke(parent, new Object[] { this }); 542 | } catch (Exception e) { 543 | System.err.println("error, disabling penScrollEvent()"); 544 | e.printStackTrace(); 545 | penScrollEventMethod = null; 546 | } 547 | } 548 | } 549 | 550 | public void penTock(long availableMillis) { 551 | } 552 | 553 | private void welcome() { 554 | System.out.println("##library.name## ##library.prettyVersion## by ##author##"); 555 | } 556 | } 557 | -------------------------------------------------------------------------------- /src/codeanticode/tablet/WindowPenClip.java: -------------------------------------------------------------------------------- 1 | package codeanticode.tablet; 2 | 3 | import com.jogamp.newt.Window; 4 | import java.awt.geom.Point2D; 5 | import java.awt.Point; 6 | import jpen.owner.PenClip; 7 | 8 | final class WindowPenClip implements PenClip { 9 | 10 | final WindowPenOwner windowPenOwner; 11 | 12 | public WindowPenClip(WindowPenOwner windowPenOwner) { 13 | this.windowPenOwner = windowPenOwner; 14 | } 15 | 16 | @Override 17 | public void evalLocationOnScreen(Point pointOnScreen) { 18 | // -> called holding the pen scheduler lock 19 | pointOnScreen.x = pointOnScreen.y = 0; 20 | com.jogamp.nativewindow.util.Point joglPoint = windowPenOwner.getWindow().getLocationOnScreen(null); 21 | pointOnScreen.x = joglPoint.getX(); 22 | pointOnScreen.y = joglPoint.getY(); 23 | } 24 | 25 | @Override 26 | public boolean contains(Point2D.Float point) { 27 | // -> called holding the pen scheduler lock 28 | if (point.x < 0 || point.y < 0) 29 | return false; 30 | Window window = windowPenOwner.getWindow(); 31 | return point.x <= window.getWidth() && point.y <= window.getHeight(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/codeanticode/tablet/WindowPenOwner.java: -------------------------------------------------------------------------------- 1 | package codeanticode.tablet; 2 | 3 | import com.jogamp.newt.event.MouseAdapter; 4 | import com.jogamp.newt.event.MouseEvent; 5 | import com.jogamp.newt.Window; 6 | import java.util.Arrays; 7 | import java.util.Collection; 8 | import jpen.owner.PenClip; 9 | import jpen.owner.PenOwner; 10 | import jpen.PenEvent; 11 | import jpen.PenProvider; 12 | import jpen.provider.osx.CocoaProvider; 13 | import jpen.provider.wintab.WintabProvider; 14 | import jpen.provider.xinput.XinputProvider; 15 | 16 | public class WindowPenOwner implements PenOwner { 17 | 18 | private PenManagerHandle penManagerHandle; 19 | private final WindowPenClip WindowPenClip = new WindowPenClip(this); 20 | private final Window window; 21 | private volatile boolean mayBeDraggingOut; 22 | 23 | public WindowPenOwner(Window window) { 24 | this.window = window; 25 | } 26 | 27 | public Window getWindow() { 28 | return window; 29 | } 30 | 31 | @Override 32 | public void setPenManagerHandle(final PenManagerHandle penManagerHandle) { 33 | this.penManagerHandle = penManagerHandle; 34 | window.addMouseListener(new MouseAdapter() { 35 | @Override 36 | public void mouseEntered(MouseEvent ev) { 37 | mayBeDraggingOut = true; 38 | // escape from the EDT to avoid thread-safety issues... 39 | new Thread(new Runnable() { 40 | public void run() { 41 | penManagerHandle.setPenManagerPaused(false); 42 | } 43 | }).start(); 44 | } 45 | 46 | @Override 47 | public void mouseExited(MouseEvent ev) { 48 | mayBeDraggingOut = false; 49 | // escape from the EDT to avoid thread-safety issues... 50 | // Note: this has a side effect: some level events continue to 51 | // be fired for a "very short time" after the mouse has exited, 52 | // we would have to modify jpen internals to filter them out if 53 | // necessary... 54 | // let me know if this needs to be done for your use case. 55 | new Thread(new Runnable() { 56 | public void run() { 57 | penManagerHandle.setPenManagerPaused(true); 58 | } 59 | }).start(); 60 | } 61 | }); 62 | } 63 | 64 | @Override 65 | public Collection getPenProviderConstructors() { 66 | return Arrays.asList(new PenProvider.Constructor[] { 67 | // Note: do you need a newt mouse/keyboard provider (so that regular 68 | // newt mouse events/keyboard are fired as jpen events too)? 69 | new XinputProvider.Constructor(), new WintabProvider.Constructor(), 70 | new CocoaProvider.Constructor(), }); 71 | } 72 | 73 | @Override 74 | public PenClip getPenClip() { 75 | return WindowPenClip; 76 | } 77 | 78 | @Override 79 | public boolean isDraggingOut() { 80 | return mayBeDraggingOut; 81 | } 82 | 83 | @Override 84 | public Object evalPenEventTag(PenEvent ev) { 85 | return null; 86 | } 87 | 88 | @Override 89 | public boolean enforceSinglePenManager() { 90 | return true; 91 | } 92 | } -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | ##library.name## 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 31 | 32 | 44 | 45 |
46 | 47 |
48 |

##library.name##

49 |

50 | A library by ##author.name## for the Processing programming environment.
51 | Last update, ##date##. 52 |

53 |

54 | ##library.sentence##
55 | ##library.paragraph##
56 | Feel free to replace this paragraph with a description of the library.
57 | Contributed libraries are developed, documented, and maintained by members of the Processing community. Further directions are included with each library. For feedback and support, please post to the Discourse. We strongly encourage all libraries to be open source, but not all of them are. 58 |

59 |
60 | 61 | 62 | 63 |
64 |

Download

65 |

66 | Download ##library.name## version ##library.prettyVersion## (##library.version##) in 67 | .zip format. 68 |

69 |

70 | Download last version compatible with Processing 2.x in 71 | .zip format. 72 |

73 |

Installation

74 |

75 | Unzip and put the extracted ##project.name## folder into the libraries folder of your Processing sketches. Reference and examples are included in the ##project.name## folder. 76 |

77 |
78 | 79 | 80 |
81 |

Keywords. ##library.keywords##

82 |

Reference. Have a look at the javadoc reference here. A copy of the reference is included in the .zip as well.

83 |

Source. The source code of ##library.name## is available at ##source.host##, and its repository can be browsed here.

84 |
85 | 86 | 87 |
88 |

Examples

89 |

Find a list of examples in the current distribution of ##library.name##, or have a look at them by following the links below.

90 |
    91 | ##examples## 92 |
93 |
94 | 95 | 96 |
97 |

Tested

98 |

99 | 100 | Platform ##tested.platform## 101 | 102 | 103 |
Processing ##tested.processingVersion## 104 | 105 | 106 |
Dependencies ##library.dependencies## 107 |

108 |
109 | 110 | 111 | 112 | 124 | 125 | 126 | 131 | 132 | 133 | 137 | 138 | 139 |
140 |
141 | 142 | 145 |
146 | 147 | -------------------------------------------------------------------------------- /web/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeanticode/tablet/c2acbc8fc0c1fb7460d737ff9000ff8a36667ab7/web/logo.jpg -------------------------------------------------------------------------------- /web/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* processingLibs style by andreas schlegel, sojamo. */ 2 | 3 | 4 | * { 5 | margin:0; 6 | padding:0; 7 | border:0; 8 | } 9 | 10 | 11 | body { 12 | font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 13 | font-size : 100%; 14 | font-size : 0.70em; 15 | font-weight : normal; 16 | line-height : normal; 17 | } 18 | 19 | 20 | 21 | #container { 22 | margin-left:64px; 23 | background-color:#fff; 24 | } 25 | 26 | #header { 27 | float:left; 28 | padding-top:24px; 29 | padding-bottom:48px; 30 | } 31 | 32 | #menu { 33 | margin-top:16px; 34 | float:left; 35 | margin-bottom:64px; 36 | } 37 | 38 | 39 | #about, 40 | #download, 41 | #examples, 42 | #demos, 43 | #misc { 44 | width:480px; 45 | float:left; 46 | margin-right:24px; 47 | } 48 | 49 | 50 | #resources, #info { 51 | width:320px; 52 | float:left; 53 | } 54 | 55 | 56 | .clear { 57 | clear:both; 58 | } 59 | 60 | #footer { 61 | margin-top:300px; 62 | height:20px; 63 | margin-bottom:32px; 64 | } 65 | 66 | 67 | ul { 68 | list-style:none; 69 | padding:0; 70 | margin:0; 71 | } 72 | 73 | 74 | #menu ul li, #subMenu ul li { 75 | float:left; 76 | padding-right:6px; 77 | } 78 | 79 | 80 | 81 | 82 | 83 | 84 | /* Headings */ 85 | 86 | h1 { 87 | font-size:2em; 88 | font-weight:normal; 89 | } 90 | 91 | 92 | h2, h3, h4, h5, th { 93 | font-size:1.3em; 94 | font-weight:normal; 95 | margin-bottom:4px; 96 | } 97 | 98 | 99 | 100 | p { 101 | font-size:1em; 102 | width:90%; 103 | margin-bottom:32px; 104 | } 105 | 106 | 107 | pre, code { 108 | font-family:"Courier New", Courier, monospace; 109 | font-size:1em; 110 | line-height:normal; 111 | } 112 | 113 | 114 | 115 | 116 | hr { 117 | border:0; 118 | height:1px; 119 | margin-bottom:24px; 120 | } 121 | 122 | 123 | a { 124 | text-decoration: underline; 125 | font-weight: normal; 126 | } 127 | 128 | 129 | a:hover, 130 | a:active { 131 | text-decoration: underline; 132 | font-weight: normal; 133 | } 134 | 135 | 136 | a:visited, 137 | a:link:visited { 138 | text-decoration: underline; 139 | font-weight: normal; 140 | } 141 | 142 | 143 | 144 | img { 145 | border: 0px solid #000000; 146 | } 147 | 148 | 149 | 150 | 151 | 152 | /* COLORS */ 153 | 154 | 155 | body { 156 | color : #333; 157 | background-color :#fff; 158 | } 159 | 160 | 161 | #header { 162 | background-color:#fff; 163 | color:#333; 164 | } 165 | 166 | 167 | 168 | h1, h2, h3, h4, h5, h6 { 169 | color:#666; 170 | } 171 | 172 | 173 | pre, code { 174 | color: #000000; 175 | } 176 | 177 | 178 | a,strong { 179 | color: #333; 180 | } 181 | 182 | 183 | a:hover, 184 | a:active { 185 | color: #333; 186 | } 187 | 188 | 189 | a:visited, 190 | a:link:visited { 191 | color: #333; 192 | } 193 | 194 | 195 | #footer, #menu { 196 | background-color:#fff; 197 | color:#333; 198 | } 199 | 200 | 201 | #footer a, #menu a { 202 | color:#333; 203 | } 204 | --------------------------------------------------------------------------------