simple sketch won't run in windows, neither application or applet - please help (processingjs only in Chrome)
in
Integration and Hardware
•
1 year ago
I have this simple sketch. No libraries, nor OpenGL, video...
It works great on the ide (mac), and mac exported application.
Exported as an applet won't run. Neither mac nor windows. Not chrome, safari or firefox.
Using processingjs (a little adaptation for fonts etc) works fine in mac, but only in chrome at windows (xp and 7)
The windows application don't run. Only message is "could not create java virtual machine"
So i'm out of option to share with windows folks...
Please help.
here the log for applet version with chrome in mac:
load: class Cores_Ciclos_06.class not found.
java.lang.ClassNotFoundException: Cores_Ciclos_06.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:195)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:249)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:690)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3045)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1497)
at java.lang.Thread.run(Thread.java:680)
Exception: java.lang.ClassNotFoundException: Cores_Ciclos_06.class
here the applet url
and
here the processingjs version
and finally the code
- /* @pjs font="AppleSDGothicNeo-Medium.otf,Avenir Next.ttc"; */
- float R = 63; /// actually those first values are not being used
- float G = 128; /// but are here to not leave them unitialized
- float B = 128;
- float hu = 180;
- float sa = 50;
- float br = 50;
- color back = color (30, 30, 30); ////some drawing colors
- color filler = color ( R, G, B);
- color border = color (35, 35, 35);
- PGraphics hueImg, satImg, brImg; // imgs for sliders lable
- PFont font, font3;
- // background and canvas vars
- int halfW, halfH; // wait for size...
- int sqSize = 400;
- int backSqSize = 80;
- int margin = 30;
- int slidersInterval;
- // Sliders
- VSlider[] rgbSliders = new VSlider[3]; ///RGB
- VSlider[] hsbSliders = new VSlider[3]; ///HSB
- // control
- boolean mouseUnclicked = false;
- boolean rgbMode = true;
- void setup()
- {
- size(750, 750);
- halfW = width/2;
- halfH = height/2;
- slidersInterval = (width - (sqSize + backSqSize))/8;
- /// initialize RGB and HSV sliders (posX, minValue, maxValue)
- for (int i = 0; i < rgbSliders.length;i++)
- {
- rgbSliders[i] = new VSlider(margin + slidersInterval* i, 0, 255);
- }
- rgbSliders[0].setName("R");
- rgbSliders[1].setName("G");
- rgbSliders[2].setName("B");
- /// HSB sliders have two diff ranges...
- hsbSliders[0] = new VSlider(width - margin - slidersInterval* 2, 0, 360, "H");
- hsbSliders[1] = new VSlider(width - margin - slidersInterval* 1, 0, 100, "S" );
- hsbSliders[2] = new VSlider(width - margin - slidersInterval* 0, 0, 100, "Br");
- /// initial canvas color
- rgbSliders[0].setVal(64.5);
- rgbSliders[1].setVal(128);
- rgbSliders[2].setVal(128);
- /// draw hue scale
- hueImg = createGraphics (9, 8, P2D);
- hueImg.beginDraw();
- hueImg.colorMode(HSB, 360, 100, 100);
- for (int i = 0; i<= hueImg.width; i++)
- {
- hueImg.stroke(i*(360/8)+20, 100, 100);
- hueImg.line(i, 0, i, height);
- }
- hueImg.endDraw();
- /// draw saturation scale
- satImg = createGraphics (9, 8, P2D);
- satImg.beginDraw();
- satImg.colorMode(HSB, 360, 100, 100);
- for (int i = 0; i<= satImg.width; i++)
- {
- satImg.stroke(270, i*(100/8)-15, 100);
- satImg.line(i, 0, i, height);
- }
- satImg.endDraw();
- /// draw brightness scale
- brImg = createGraphics (9, 8, P2D);
- brImg.beginDraw();
- brImg.colorMode(HSB, 360, 100, 100);
- for (int i = 0; i<= satImg.width; i++)
- {
- brImg.stroke(0, 0, 115 - i*(100/8));
- brImg.line(i, 0, i, height);
- }
- brImg.endDraw();
- //font = loadFont("Monospaced-48.vlw");
- font = loadFont("AvenirNext-Regular-48.vlw");
- font3 = loadFont("AppleSDGothicNeo-Medium-48.vlw");
- background(back);
- }// end of setup
- void draw ()
- {
- background(back);
- /// test for RGB or HSB mode
- /// means; one is accepting inputs and other following
- if (mouseX < width/2)
- {
- rgbMode = true;
- }
- else
- {
- rgbMode = false;
- }
- ///draw border not using stroke... opsgl
- noStroke();
- fill (border);
- rectMode(CENTER);
- rect( halfW, halfH, sqSize + backSqSize, sqSize + backSqSize);
- /// draw canvas in RGB mode
- if (rgbMode)
- {
- colorMode(RGB, 255);
- noStroke();
- filler = color ( R, G, B);
- fill (filler);
- rectMode(CENTER);
- rect(halfW, halfH, sqSize, sqSize);
- /// sliders goC() and goI() - i was having problems with overloading and processingjs...
- /// just activate and draw
- R = rgbSliders[0].goC(color(255, 0, 0));
- G = rgbSliders[1].goC(color(0, 255, 0));
- B = rgbSliders[2].goC(color(0, 0, 255));
- hsbSliders[0].goI(hueImg);
- hsbSliders[1].goI(satImg);
- hsbSliders[2].goI(brImg);
- /// changing color mode and read colors in new mode
- colorMode(HSB, 360, 100, 100);
- hu = hue(filler);
- sa = saturation(filler);
- br = brightness(filler);
- ///setting value
- hsbSliders[0].setVal(hu);
- hsbSliders[1].setVal(sa);
- hsbSliders[2].setVal(br);
- }
- else if (!rgbMode)
- {
- /// the same other way arround
- colorMode(HSB, 360, 100, 100);
- noStroke();
- filler = color ( hu, sa, br);
- fill (filler);
- rectMode(CENTER);
- rect(halfW, halfH, sqSize, sqSize);
- /// sliders
- hu = hsbSliders[0].goI(hueImg);
- sa = hsbSliders[1].goI(satImg);
- br = hsbSliders[2].goI(brImg);
- rgbSliders[0].goC(color(255, 0, 0));
- rgbSliders[1].goC(color(0, 255, 0));
- rgbSliders[2].goC(color(0, 0, 255));
- colorMode(RGB, 255);
- R = red(filler);
- G = green(filler);
- B = blue(filler);
- rgbSliders[0].setVal(R);
- rgbSliders[1].setVal(G);
- rgbSliders[2].setVal(B);
- }
- }//end of draw
- void mousePressed()
- {
- mouseUnclicked = false; // locking button pressed even outside of knob if had cliked inside
- }
- void mouseReleased()
- {
- mouseUnclicked = true;
- }
- class VSlider
- {
- /// some colors to draw with
- color lineColor;
- color knobColor;
- color lineUnsel = color(40, 40, 40);
- color knobUnsel = color(75, 75, 75);
- color lineFocus = color(50, 50, 50);
- color knobFocus = color(85, 85, 85);
- color lineSel = color(60, 60, 60);
- color knobSel = color(115, 115, 115);
- float x; // position along x axis
- int knobSize = 12;
- /// align with border square
- float halfSliderLength = (sqSize + backSqSize)/2.0;
- float upperY = halfH - halfSliderLength;
- float lowerY = halfH + halfSliderLength;
- /// values for slider
- float maxValue = -1; // a not logical initialization
- float minValue = -1;
- float knobValue = lowerY - knobSize/2; // default to bottom
- boolean locked = false;
- String name ="";
- float retorno = -12345; // a not logical initialization
- VSlider() { // default constructor
- };
- /// with name
- VSlider (float _x, float _maxValue, float _minValue, String _name)
- {
- x = _x;
- maxValue = _maxValue;
- minValue = _minValue;
- name = _name;
- }
- /// without name
- VSlider (float _x, float _maxValue, float _minValue)
- {
- x = _x;
- maxValue = _maxValue;
- minValue = _minValue;
- name = "!NOTNAMED!";
- }
- /// add a colored square to sliders and diplay text % included
- float goC(color c)
- {
- colorMode(RGB, 255);
- noStroke();
- fill (c);
- rect(x, (upperY+lowerY)/2, 8, 8);
- displayNumbers();
- displayPercents(); /// only rgb needs
- return go();
- }// eof go(color)
- /// add an image square to sliders and diplay text
- float goI(PImage img)
- {
- image(img, x-(img.width/2), ((upperY+lowerY)/2) - img.height/2 );//upperY - 11 - img.height/2
- displayNumbers();
- return go();
- }//eof go(image)
- float go ()
- {
- /// draw slider
- colorMode(RGB, 255);
- stroke(lineColor);
- strokeWeight(2);
- line( x, upperY, x, lowerY);
- /// test for mouse releasing to unlock knob
- if (mouseUnclicked && locked)
- {
- locked = false;
- }
- /// test for proper click
- if (isOver() && mousePressed && !locked)
- {
- locked = true;
- }
- if (locked)
- {
- /// assign mouse y to knobvalue. constrained for darwing
- /// here i intruduces the rounding error...
- knobValue = constrain(mouseY, upperY + knobSize/2, lowerY - knobSize/2);
- /// paint if locked
- lineColor = lineSel;
- knobColor = knobSel;
- }
- else if (!locked)
- {
- /// test for focus if/elseif/elseif... for painting
- /// if slider is in the same vertical half of screen as mouse it is active
- if ( x > width/2 && mouseX > width/2 )
- {
- lineColor = lineFocus;
- knobColor = knobFocus;
- }
- else if (x > width/2 && mouseX < width/2)
- {
- lineColor = lineUnsel;
- knobColor = knobUnsel;
- }
- else if (x < width/2 && mouseX > width/2)
- {
- lineColor = lineUnsel;
- knobColor = knobUnsel;
- }
- else
- {
- lineColor = lineFocus;
- knobColor = knobFocus;
- }
- }
- ///drawKnob
- noStroke();
- fill(knobColor);
- ellipse( x, knobValue, knobSize, knobSize);
- /// tool tip
- if (isOver() || locked)
- {
- textFont(font3, knobSize - 2);
- color addC = color(50);
- color tempC =blendColor(knobColor, addC, ADD);
- fill(tempC);
- text(name, x - knobSize - 3, knobValue - knobSize + 10);
- }
- retorno = map(knobValue, upperY + knobSize/2, lowerY - knobSize/2, minValue, maxValue);
- return retorno;
- }//end of go()
- void setName(String newName)
- {
- name = newName;
- }//end fo setName()
- /// converts to %
- float inPercent(float value, float percentMax) // assuming 0 as lowest value
- {
- return (float)((value*100.0f)/percentMax);
- }// eof inPercent()
- ///
- void setVal(float value)
- {
- if (value >= minValue)
- {
- }
- else
- {
- knobValue = map(value, minValue, maxValue, upperY + knobSize/2.0, lowerY - knobSize/2.0);
- }
- }
- ///
- void displayNumbers()
- {
- String valueToDisplay = nf((int)(go()), 3);
- pushMatrix();
- textFont(font, 40);
- textAlign(LEFT, TOP);
- rotate(-HALF_PI);
- translate(-lowerY - textWidth(valueToDisplay)-10, x-19);
- text(valueToDisplay, 0, 0);
- popMatrix();
- textAlign(LEFT);
- }//eof displayNumbers
- ///
- void displayPercents()
- {
- float percent = inPercent(go(), 255);
- String valueInPercent = nf(percent, 3, 2) + "%";
- pushMatrix();
- textFont(font, 14);
- textAlign(LEFT, TOP);
- rotate(-HALF_PI);
- translate(-upperY - textWidth(valueInPercent), x-16);
- text(valueInPercent, 0, 0);
- popMatrix();
- textAlign(LEFT);
- }//eof displayPercents
- /// debug help
- void debug()
- {
- print(" "+name+" "+ knobValue+ " returns "+ retorno);
- }//eof debug()
- void debugln()
- {
- println(" "+name+" "+ knobValue+ " returns "+ retorno);
- }// eof debugln()
- /// mouse detecting stuff
- boolean isOver()
- {
- float disX = x - mouseX;
- float disY = knobValue - mouseY;
- if (sqrt(sq(disX) + sq(disY)) < knobSize/2 ) {
- return true;
- }
- else {
- return false;
- }
- }
- }// end of Slider class
1