Including shared pde files across projects

Thanks, soon as I decide it’s not something I am still doing!

Even “jdk1.8.0_101” is still pretty old. If you look inside my Palette.jar file, at the content of its “MANIFEST.MF”, you’ll see it was created by “jdk1.8.0_121”: :coffee:

Manifest-Version: 1.0
Created-By: 1.8.0_121 (Oracle Corporation)

However, “jdk1.8.0_121” is old too, given latest Java 8 is “jdk1.8.0_172” “jdk1.8.0_181”: :scream:
https://www.Oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Actually, I’m right now downloading it. And gonna recompile “Palette.java” w/ latest Java 8 version and upload it to my repo. :sunglasses:

I find it editing Windows’ PATH system variable w/ “Rapid Environment Editor” utility much easier & safer: :man_mechanic:

My new Java PATH’s gonna be: “ProgramFiles\Java\jdk1.8.0_172\bin” :cowboy_hat_face:

2 Likes

The following diagram attempts to give a graphical description of the class java creation process that was implemented with GoToLoop’s GitHub repository.

The primary aim was to demonstrate a java library (.jar) that could provide variables to multiple Processing projects.

3 Likes

Nice diagram! Uploaded it into my repo: :grinning:

https://GitHub.com/GoToLoop/Processing_Jar_Creation/blob/master/PaletteJar.jpg

2 Likes

@malcolm_gc===
just to say that with the palette example (library) the jar i have made with Eclipse && the other one with java tools works and dont fire error after added to the libraries folder

also : ’ = minut, “” = second

@kfrajer===
as for the second example i misunderstood: it s not only a jar but an executable jar…In this case you have to add to your manifest what is the main entry class, then run the command jar cvmf MANIFEST.MF Programme.jar *.class
m means “use my[provided] manifest”
and also : . bat means nothing for OSX which uses bash…

for akenaton

Thanks ,

Now that I have something that works my plan is to change it to names that are more sensible and perhaps post it back as a general example for others. I am also interested in why Eclipse builds a library that does not return an error message, there has to be a reason for that I would like to be able to modify what GoToLoop has provided to build a library that does not give an error. So I will install Eclipse and give that at go eventually.

All this because I wanted WHITE RED AND BLUE.

My “library?!” is perfectly valid & doesn’t throw any errors/warnings! :triumph:

It’s a PDE glitch which displays a “No library found for…” red warning when we import static any library! :japanese_ogre:

Just comment out import static malcolm.Palette.*; and no ugly red warning will show up: :wink:

/**
 * PaletteJarSketch (v1.1.1)
 * GoToLoop (2018/Jul/13)
 *
 * https://Discourse.Processing.org/t/
 * including-shared-pde-files-across-projects/1701/47
 */

import malcolm.Palette;
//import static malcolm.Palette.*;

background(Palette.BLUE);

strokeWeight(3.5);
stroke(Palette.RED);
fill(Palette.YELLOW);

ellipse(width>>1, height>>1, width>>1, height>>1);
1 Like

For me if I change import static malcolm.Palette.; to import malcolm.Palette.;
I get an error BLUE cannot be resolved to a variable .

I appreciate the effort of those that responded and I now have a better grasp of what’s going on

I particularly appreciate GoToLoops GitHub stuff so I have given that a go myself and have modified GoToLoops stuff a bit and added a couple of graphic files.

My version is at https://github.com/malcolm-gc/template_for_jar- it is slightly different it has I think a better naming for the package and library common instead of Malcolm AND I added a second java file that contains a class with a few functions AND the batch file now creates the library directory and copies the jar file to it.

I expect that my template_for_jar will undergo some changes, I have to get rid of the warning still but as I had not used GitHub before it was a learning experience, albeit less painful than jar files.

I didn’t notice that you had added background(Palette.BLUE); mea culpa :roll_eyes:

Yes that fixes the silly error message.

I am not sure which is the better option having to stick Palette. in front of variables or living with the error message. :thinking: In the new common.jar I created there are class functions and they don’t throw an error its just those ints. I am sure that I read somewhere that it was necessary to declare the import as static. far variables but not sure where I read it.

If its a glitch with the IDE then tProcessing should fix it. :rage: I will report it using the link you provided earlier.

Thanks so much !

import static java.util.Map.Entry; // From Java. No red "not found" warning.
import static processing.core.PImage.*; // From P5. No red "not found" warning.

import controlP5.ControlP5; // Needed if we use `import static` for a 3rd-party lib!
import static controlP5.ControlP5.*; // Displays a red "not found" warning!

println(hex(ALPHA_MASK)); // PImage.ALPHA_MASK constant (0xFF000000).
println(ACTION_ENTER); // ControlP5.ACTION_ENTER constant (6).

exit();

I thought at first you might be giving me a means by which to resolve the errors , so I mucked around for a bit trying to make my message go away and it wouldn’t

but I am thinking that you have just provided additional examples

the java and processing libraries are ok with static i.e no warning message

but static controlP5 gives a warning

I will add that info to the bug report if you could confirm that they are just extra examples

thanks

Mostly to state only 3rd-party libraries got that red warning glitch when we use static import on them. :roll_eyes:

Plus the extra glitch that we need a regular import in order to use static import for 3rd-party libraries: :astonished:

Thanks I shall update the bug

Hello! I know this is not related to this topic and i hope you don’t mind, but since you have used a palette as an example, I’ve decided to leave here an interface Palette with 138 colors with their relative names for anyone interested in creating a palette library :blush:

public interface Palette {
    static final int
            BLACK                   = 0xff000000,
            DIM_GRAY                = 0xff696969,
            GRAY                    = 0xff808080,
            DARK_GRAY               = 0xffA9A9A9,
            SILVER                  = 0xffC0C0C0,
            LIGHT_GRAY              = 0xffD3D3D3,
            GAINSBORO               = 0xffDCDCDC,
            WHITE_SMOKE             = 0xffF5F5F5,
            WHITE                   = 0xffFFFFFF,
            SNOW                    = 0xffFFFAFA,
            AZURE                   = 0xffF0FFFF,
            IVORY                   = 0xffFFFFF0,
            HONEYDEW                = 0xffF0FFF0,
            GHOST_WHITE             = 0xffF8F8FF,
            ALICE_BLUE              = 0xffF0F8FF,
            FLORAL_WHITE            = 0xffFFFAF0,
            LAVENDER                = 0xffE6E6FA,
            LIGHT_STEEL_BLUE        = 0xffB0C4DE,
            LIGHT_SLATE_GRAY        = 0xff778899,
            SLATE_GRAY              = 0xff708090,
            MARRON                  = 0xff800000,
            DARK_RED                = 0xff8B0000,
            BROWN                   = 0xffA52A2A,
            FIREBRICK               = 0xffB22222,
            CRIMSON                 = 0xffDC143C,
            RED                     = 0xffFF0000,
            TOMATO                  = 0xffFF6347,
            CORAL                   = 0xffFF7F50,
            INDIAN_RED              = 0xffCD5C5C,
            LIGHT_CORAL             = 0xffF08080,
            DARK_SALMON             = 0xffE9967A,
            SALMON                  = 0xffFA8072,
            LIGHT_SALMON            = 0xffFFA07A,
            ORANGE_RED              = 0xffFF4500,
            DARK_ORANGE             = 0xffFF8C00,
            ORANGE                  = 0xffFFA500,
            GOLD                    = 0xffFFD700,
            DARK_GOLDEN_ROD         = 0xffB8860B,
            GOLDEN_ROD              = 0xffDAA520,
            PALE_GOLDEN_ROD         = 0xffEEE8AA,
            DARK_KHAKI              = 0xffBDB76B,
            KHAKI                   = 0xffF0E68C,
            OLIVE                   = 0xff808000,
            YELLOW                  = 0xffFFFF00,
            YELLOW_GREEN            = 0xff9ACD32,
            DARK_OLIVE_GREEN        = 0xff556B2F,
            OLIVE_DRAB              = 0xff6B8E23,
            LAWN_GREEN              = 0xff7CFC00,
            CHART_REUSE             = 0xff7FFF00,
            GREEN_YELLOW            = 0xffADFF2F,
            DARK_GREEN              = 0xff006400,
            GREEN                   = 0xff008000,
            FOREST_GREEN            = 0xff228B22,
            LIME                    = 0xff00FF00,
            LIME_GREEN              = 0xff32CD32,
            LIGHT_GREEN             = 0xff90EE90,
            PALE_GREEN              = 0xff98FB98,
            DARK_SEA_GREEN          = 0xff8FBC8F,
            MEDIUM_SPRING_GREEN     = 0xff00FA9A,
            SPRING_GREEN            = 0xff00FF7F,
            SEA_GREEN               = 0xff2E8B57,
            MEDIUM_AQUA_MARINE      = 0xff66CDAA,
            MEDIUM_SEA_GREEN        = 0xff3CB371,
            LIGHT_SEA_GREEN         = 0xff20B2AA,
            DARK_SLATE_GRAY         = 0xff2F4F4F,
            TEAL                    = 0xff008080,
            DARK_CYAN               = 0xff008B8B,
            AQUA                    = 0xff00FFFF,
            CYAN                    = 0xff00FFFF,
            LIGHT_CYAN              = 0xffE0FFFF,
            DARK_TURQUOISE          = 0xff00CED1,
            TURQUOISE               = 0xff40E0D0,
            MEDIUM_TURQUOISE        = 0xff48D1CC,
            PALE_TURQUOISE          = 0xffAFEEEE,
            AQUA_MARINE             = 0xff7FFFD4,
            POWDER_BLUE             = 0xffB0E0E6,
            CADET_BLUE              = 0xff5F9EA0,
            STEEL_BLUE              = 0xff4682B4,
            CORN_FLOWER_BLUE        = 0xff6495ED,
            DEEP_SKY_BLUE           = 0xff00BFFF,
            DODGER_BLUE             = 0xff1E90FF,
            LIGHT_BLUE              = 0xffADD8E6,
            SKY_BLUE                = 0xff87CEEB,
            LIGHT_SKY_BLUE          = 0xff87CEFA,
            MIDNIGHT_BLUE           = 0xff191970,
            NAVY                    = 0xff000080,
            DARK_BLUE               = 0xff00008B,
            MEDIUM_BLUE             = 0xff0000CD,
            BLUE                    = 0xff0000FF,
            ROYAL_BLUE              = 0xff4169E1,
            BLUE_VIOLET             = 0xff8A2BE2,
            INDIGO                  = 0xff4B0082,
            DARK_SLATE_BLUE         = 0xff483D8B,
            SLATE_BLUE              = 0xff6A5ACD,
            MEDIUM_SLATE_BLUE       = 0xff7B68EE,
            MEDIUM_PURPLE           = 0xff9370DB,
            DARK_MAGENTA            = 0xff8B008B,
            DARK_VIOLET             = 0xff9400D3,
            DARK_ORCHID             = 0xff9932CC,
            MEDIUM_ORCHID           = 0xffBA55D3,
            PURPLE                  = 0xff800080,
            THISTLE                 = 0xffD8BFD8,
            PLUM                    = 0xffDDA0DD,
            VIOLET                  = 0xffEE82EE,
            MAGENTA                 = 0xffFF00FF,
            ORCHID                  = 0xffDA70D6,
            MEDIUM_VIOLET_RED       = 0xffC71585,
            PALE_VIOLET_RED         = 0xffDB7093,
            DEEP_PINK               = 0xffFF1493,
            HOT_PINK                = 0xffFF69B4,
            LIGHT_PINK              = 0xffFFB6C1,
            PINK                    = 0xffFFC0CB,
            ANTIQUE_WHITE           = 0xffFAEBD7,
            BEIGE                   = 0xffF5F5DC,
            BISQUE                  = 0xffFFE4C4,
            BLANCHED_ALMOND         = 0xffFFEBCD,
            WHEAT                   = 0xffF5DEB3,
            CORN_SILK               = 0xffFFF8DC,
            LEMON_CHIFFON           = 0xffFFFACD,
            LIGHT_GOLDEN_ROD_YELLOW = 0xffFAFAD2,
            LIGHT_YELLOW            = 0xffFFFFE0,
            SADDLE_BROWN            = 0xff8B4513,
            SIENNA                  = 0xffA0522D,
            CHOCOLATE               = 0xffD2691E,
            PERU                    = 0xffCD853F,
            SANDY_BROWN             = 0xffF4A460,
            BURLY_WOOD              = 0xffDEB887,
            TAN                     = 0xffD2B48C,
            ROSY_BROWN              = 0xffBC8F8F,
            MOCCASIN                = 0xffFFE4B5,
            NAVAJO_WHITE            = 0xffFFDEAD,
            PEACH_PUFF              = 0xffFFDAB9,
            MISTY_ROSE              = 0xffFFE4E1,
            LAVENDER_BLUSH          = 0xffFFF0F5,
            LINEN                   = 0xffFAF0E6,
            OLD_LACE                = 0xffFDF5E6,
            PAPAYA_WHIP             = 0xffFFEFD5,
            SEA_SHELL               = 0xffFFF5EE,
            MINT_CREAM              = 0xffF5FFFA;
}

Here’s a nice sketch that you can use to test it:

import palette.Palette;

Windmill windmill;

void setup() {
  size(400, 400);
  windmill = new Windmill();
}

void draw() {
  background(Palette.SKY_BLUE);

  fill(Palette.OLIVE_DRAB);
  rect(0, 2*height/3, width, height);

  noStroke();
  fill(Palette.AZURE);
  ellipse(width/4, height/5, 150, 75);
  ellipse(width/2, height/7, 100, 50);

  windmill.show();
}

class Windmill implements Palette {
  void show() {
    pushStyle();
    rectMode(CENTER);
    translate(width>>1, height>>1);

    stroke(BLACK);
    fill(SIENNA); //dome
    ellipse(0, -10, 80, 80);

    fill(KHAKI); //cylinder
    rect(0, 50, 80, 120);

    fill(SADDLE_BROWN); //door
    rect(25, 85, 15, 50);

    fill(IVORY); //blades
    for (int i = 0; i<3; i++) {
      float x1 = 100 * cos(TWO_PI/3 * i + (frameCount * 0.02));
      float y1 = 100 * sin(TWO_PI/3 * i + (frameCount * 0.02));
      float x2 = 100 * cos(TWO_PI/3 * i + PI/5 + (frameCount * 0.02));
      float y2 = 100 * sin(TWO_PI/3 * i + PI/5 + (frameCount * 0.02));
      triangle(0, 0, x1, y1, x2, y2);
    }   
    fill(GOLD); //axis
    ellipse(0, 0, 10, 10);
    popStyle();
  }
}

Again, sorry if this is not related to the topic :blush: hope you like it

3 Likes

Very nice windmill colorful animation! :wind_face:

Just a little detail: if we have import palette.Palette; in the sketch, we need to have package palette; in “Palette.java”. :innocent:

And while I’m at it, made some very small optimizations to your loop: :sunglasses:

    fill(IVORY); //blades
    final float step = .02 * frameCount;

    for (int i = 0; i < 3; ++i) {
      final float x1 = 100 * cos(2*THIRD_PI * i + step);
      final float y1 = 100 * sin(2*THIRD_PI * i + step);
      final float x2 = 100 * cos(2*THIRD_PI * i + PI/5 + step);
      final float y2 = 100 * sin(2*THIRD_PI * i + PI/5 + step);

      triangle(0, 0, x1, y1, x2, y2);
    }
2 Likes