Search in sources :

Example 11 with PImage

use of processing.core.PImage in project hid-serial by rayshobby.

the class GCustomSlider method loadStyle_FromSketch.

/**
	 * Load a skin when run as an application or run locally.
	 * 
	 * @param styleFolder
	 * @param style
	 * @return true if the style loaded successfully
	 */
private boolean loadStyle_FromSketch(String style) {
    // First attempt to locate the style inside the sketch or sketch data folders
    File styleFolder = new File(winApp.dataPath(style));
    if (!styleFolder.exists())
        styleFolder = new File(winApp.sketchPath(style));
    // and if successful we are done
    if (!styleFolder.exists())
        return false;
    int fcount = 0;
    String[] names = new String[] { "centre.", "end_left.", "end_right.", "handle.", "handle_mouseover." };
    PImage[] images = new PImage[names.length];
    File[] fileList = styleFolder.listFiles();
    for (int i = 0; i < names.length; i++) {
        for (File f : fileList) {
            String filename = f.getName();
            if (filename.startsWith(names[i])) {
                images[i] = winApp.loadImage(style + "/" + filename);
                fcount++;
            }
        }
    }
    if (fcount != names.length)
        return false;
    centre = images[0];
    leftEnd = images[1];
    rightEnd = images[2];
    thumb = images[3];
    thumb_mouseover = images[4];
    return true;
}
Also used : PImage(processing.core.PImage) File(java.io.File)

Example 12 with PImage

use of processing.core.PImage in project hid-serial by rayshobby.

the class GTextIconAlignBase method setIcon.

/**
	 * Set the icon to be used and the horizontal and/or vertical icon alignment. 
	 * Use the constants in GAlign e.g. <pre>GAlign.LEFT</pre> <br>
	 * 
	 * @param fname the filename of the icon
	 * @param nbrImages number of tiled images in the icon
	 * @param horz LEFT or RIGHT
	 * @param vert TOP, MIDDLE, BOTTOM
	 */
public void setIcon(String fname, int nbrImages, GAlign horz, GAlign vert) {
    PImage iconImage = ImageManager.loadImage(winApp, fname);
    setIcon(iconImage, nbrImages, horz, vert);
}
Also used : PImage(processing.core.PImage)

Example 13 with PImage

use of processing.core.PImage in project processing by processing.

the class PSurfaceAWT method setIcon.

@Override
public void setIcon(PImage image) {
    Image awtImage = (Image) image.getNative();
    if (PApplet.platform != PConstants.MACOSX) {
        frame.setIconImage(awtImage);
    } else {
        try {
            final String td = "processing.core.ThinkDifferent";
            Class<?> thinkDifferent = Thread.currentThread().getContextClassLoader().loadClass(td);
            Method method = thinkDifferent.getMethod("setIconImage", new Class[] { java.awt.Image.class });
            method.invoke(null, new Object[] { awtImage });
        } catch (Exception e) {
            // That's unfortunate
            e.printStackTrace();
        }
    }
}
Also used : Method(java.lang.reflect.Method) PImage(processing.core.PImage) Image(java.awt.Image)

Example 14 with PImage

use of processing.core.PImage in project sirix by sirixdb.

the class SmallmultipleGUI method draw.

@Override
public void draw() {
    if (mDone) {
        mParent.pushMatrix();
        mParent.colorMode(PConstants.HSB, 360, 100, 100, 100);
        mParent.noFill();
        mParent.ellipseMode(PConstants.RADIUS);
        mParent.strokeCap(PConstants.SQUARE);
        mParent.textLeading(14);
        mParent.textAlign(PConstants.LEFT, PConstants.CENTER);
        mParent.smooth();
        mParent.stroke(255f);
        mParent.strokeWeight(2f);
        int i = 1;
        mX = 0;
        mY = 0;
        if (mBufferedImages.size() != 0) {
            mLock.acquireUninterruptibly();
            mParent.fill(360);
            mParent.noStroke();
            mParent.rect(0, 0, (float) mParent.width, (float) mParent.height);
            for (final ImageStore imageStore : mBufferedImages) {
                // .get((int)(mBuffer.width
                final PImage buffer = imageStore.mBufferedImage;
                // / 15f), 0,
                // (int)(mBuffer.width - mBuffer.width / 15f), mBuffer.height);
                mParent.image(buffer, mX, mY, buffer.width / 2f, buffer.height / 2f);
                mX += mBuffer.width / 2f;
                if (i % 2 == 0) {
                    mX -= mBuffer.width / 2f;
                    mY = mBuffer.height / 2f + 1;
                } else if (i % 3 == 0) {
                    mX = 0;
                }
                i++;
            }
            mLock.release();
            mParent.fill(0);
            mParent.textAlign(PConstants.LEFT, PConstants.TOP);
            mParent.stroke(50f);
            mParent.strokeWeight(1.5f);
            circArrow(mParent.width * 0.5f, mParent.height * 0.5f, 50, PConstants.PI, PConstants.TWO_PI * 1.25f, 10);
            mParent.text("direction", mParent.width * 0.5f - mParent.textWidth("direction") * 0.5f, mParent.height * 0.5f - (mParent.textAscent() + mParent.textDescent()) * 0.5f);
            mParent.stroke(0f);
            mParent.strokeWeight(0f);
            mParent.ellipseMode(PConstants.RADIUS);
            final SmallmultipleModel model = ((SmallmultipleModel) mControl.getModel());
            ViewUtilities.compareLegend(this);
            ViewUtilities.legend(this, model);
            mParent.textAlign(PConstants.LEFT, PConstants.CENTER);
            mParent.fill(360);
            mParent.noStroke();
            // Mouse rollover.
            if (!isShowGUI()) {
                // Mouse rollover, arc hittest vars.
                rollover();
                if (mHitItem != null && mHitItem.getGreyState() == EGreyState.NO) {
                    mX = mParent.mouseX - mParent.width / 2f;
                    mY = mParent.mouseY - mParent.height / 2f;
                    mParent.translate((float) mParent.width / 2f, (float) mParent.height / 2f);
                    // Hover items.
                    mParent.pushMatrix();
                    mParent.scale(0.5f);
                    for (i = 0; i < mRevisions; i++) {
                        final ImageStore imageStore = mBufferedImages.get(i);
                        model.setItems(i);
                        switch(i) {
                            case 0:
                                mParent.translate(-(float) mBuffer.width / 2f, -(float) mBuffer.height / 2f);
                                break;
                            case 1:
                                mParent.translate((float) mBuffer.width, 0);
                                break;
                            case 2:
                                mParent.translate(0, (float) mBuffer.height + 1);
                                break;
                            case 3:
                                mParent.translate(-(float) mBuffer.width, 0);
                                break;
                        }
                        mDepthMax = imageStore.mMaxDepth;
                        mOldDepthMax = imageStore.mOldMaxDepth;
                        for (final SunburstItem item : model) {
                            if (mKeyEquivalence.equivalent(item, mHitItem)) {
                                Draw.DRAW.drawHover(this, item);
                                break;
                            }
                        }
                    }
                    mParent.popMatrix();
                    // Rollover text.
                    if (mHitItem.getGreyState() == EGreyState.NO) {
                        mParent.strokeWeight(1f);
                        textMouseOver();
                    }
                }
            }
        }
        mParent.popMatrix();
        ViewUtilities.drawGUI(getControlP5());
    }
}
Also used : PImage(processing.core.PImage) SunburstItem(org.sirix.gui.view.sunburst.SunburstItem)

Example 15 with PImage

use of processing.core.PImage in project sirix by sirixdb.

the class SunburstGUI method fisheye.

/**
 * Fisheye transformation.
 *
 * @param pXPos
 *          X position of middle point of the transformation
 * @param pYPos
 *          Y position of middle point of the transformation
 * @param pRadius
 *          the radius to use
 */
private void fisheye(final int pXPos, final int pYPos, final int pRadius) {
    // Start point of rectangle to grab.
    final int tlx = pXPos - pRadius;
    final int tly = pYPos - pRadius;
    // Rectangle with pixels.
    final PImage pi = mParent.get(tlx, tly, pRadius * 2, pRadius * 2);
    for (int x = -pRadius; x < pRadius; x++) {
        for (int y = -pRadius; y < pRadius; y++) {
            // Rescale cartesian coords between -1 and 1.
            final float cx = (float) x / pRadius;
            final float cy = (float) y / pRadius;
            // Outside of the sphere -> skip.
            final float square = PApplet.sq(cx) + PApplet.sq(cy);
            if (square >= 1) {
                continue;
            }
            // Compute cz from cx & cy.
            final float cz = PApplet.sqrt(1 - square);
            // Cartesian coords cx, cy, cz -> spherical coords sx, sy, still in -1,
            // 1 range.
            final float sx = PApplet.atan(EFFECT_AMOUNT * cx / cz) * 2 / PConstants.PI;
            final float sy = PApplet.atan(EFFECT_AMOUNT * cy / cz) * 2 / PConstants.PI;
            // Spherical coords sx & sy -> texture coords.
            final int tx = tlx + (int) ((sx + 1) * pRadius);
            final int ty = tly + (int) ((sy + 1) * pRadius);
            // Set pixel value.
            pi.set(pRadius + x, pRadius + y, mParent.get(tx, ty));
        }
    }
    mParent.set(tlx, tly, pi);
}
Also used : PImage(processing.core.PImage)

Aggregations

PImage (processing.core.PImage)17 Color (java.awt.Color)4 File (java.io.File)2 Image (java.awt.Image)1 Point (java.awt.Point)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1 ImageIcon (javax.swing.ImageIcon)1 SunburstItem (org.sirix.gui.view.sunburst.SunburstItem)1