Package net.sf.jiga.xtended.kernel

Examples of net.sf.jiga.xtended.kernel.Monitor


    private Display(Image pdisplay, AffineTransform ptx) {

        super();

        setGroupMonitor(new Monitor());

        display = pdisplay;
        tx = ptx;
        loadResource();
        setPreferredSize(originalBox);
View Full Code Here


        setPreferredSize(psize);

        setSize(getPreferredSize());

        setGroupMonitor(new Monitor());

        display = pdisplay;
        tx = ptx;
        loadResource();
    }
View Full Code Here

            return;

        }

        final Monitor monitor = imageSynch;

        Rectangle clip = g1.getClipBounds();

        try {

            synchronized (monitor) {

                Dimension currentSize = new Dimension(getWidth(), getHeight());
                Graphics2D g = (Graphics2D) g1;

                g.clipRect(0, 0, currentSize.width, currentSize.height);
                g.setBackground(background);
                Composite cps = g.getComposite();
                g.setColor(g.getBackground());
                if (isOpaque()) {
                    g.fillRect(0, 0, currentSize.width, currentSize.height);
                }
                g.setColor(Color.BLACK);
                AffineTransform bgResizeTx = AffineTransform.getScaleInstance((double) ((float) currentSize.width) / ((float) bgImg.getWidth(this)), (double) ((float) currentSize.height) / ((float) bgImg.getHeight(this)));
                AffineTransform dispResizeTx = AffineTransform.getScaleInstance((double) ((float) currentSize.width) / ((float) display.getWidth(this)), (double) ((float) currentSize.height) / ((float) display.getHeight(this)));
                if (!currentImageSize.equals(currentSize)) {
                    mt.addImage(bgImg, hashCode(), currentSize.width, currentSize.height);
                }

                if (!tx.equals(currentTx)) {

                    Rectangle box = this.tx.createTransformedShape(new Rectangle(0, 0, display.getWidth(this), display.getHeight(this))).getBounds();

                    if (!new Dimension(display.getWidth(this), display.getHeight(this)).equals(box.getSize())) {

                        mt.addImage(display, hashCode(), box.width, box.height);

                    }

                    mt.waitForAll();

                    cps = g.getComposite();

                    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.33f));

                    if (opaque) {
                        g.drawImage(bgImg, bgResizeTx, this);
                    }

                    g.setComposite(cps);

                    g.drawImage(display, tx, this);

                    currentTx = tx;

                } else {

                    if (!currentImageSize.equals(currentSize)) {
                        mt.addImage(display, hashCode(), currentSize.width, currentSize.height);
                    }

                    mt.waitForAll();

                    cps = g.getComposite();

                    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.33f));

                    if (opaque) {
                        g.drawImage(bgImg, bgResizeTx, this);
                    }

                    g.setComposite(cps);

                    g.drawImage(display, dispResizeTx, this);

                    currentImageSize = currentSize;
                }

                mt.removeImage(bgImg, hashCode());
                mt.removeImage(display, hashCode());

                monitor.notify();

            }

        } catch (InterruptedException ex) {
View Full Code Here

    /** not implemented
   
    @see #clearResource()*/
    public Object loadResource() {

        final Monitor monitor = imageSynch;
        try {
            synchronized (monitor) {
                if (display == null) {
                    return null;
                }
                phantomImage = new PhantomReference(display, refQueue);
                String icon = "images/duke.gif";
                bgImg = ImageIO.read(getClass().getResourceAsStream(icon));
                mt = new MediaTracker(this);
                mt.addImage(bgImg, hashCode());
                mt.addImage(display, hashCode());
                mt.waitForAll();
                mt.removeImage(bgImg, hashCode());
                mt.removeImage(display, hashCode());
                if (tx != null) {
                    Display.this.tx = tx;
                } else {
                    Display.this.tx = AffineTransform.getScaleInstance(1.0, 1.0);
                }
                originalBox = new Dimension(display.getWidth(this), display.getHeight(this));
                valid = true;
                monitor.notify();
            }
        } catch (Exception ex) {
            if (JXAenvUtils._debugSys) {
                ex.printStackTrace();
            }
View Full Code Here

                        }
                        /*
                         * GLclearRegion screen
                         */
                        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
                        final Monitor monitor = offscreenSynch;
                        synchronized (monitor) {
                                synchronized (GLloaders) {
                                        for (LoadListener gl : GLloaders) {
                                                if ((gl.getLoadState() & _GLLOADSTATE_Loading) != 0) {
                                                        setLoadingState(options.MODE_STATE_LOADING_GL.bitMask(), true);
                                                        break;
                                                }
                                        }
                                }
                                ActionEvent e = new ActionEvent(this, hashCode(), "offscreen tasks");
                                GLFX._GLBeginFX(true);
                                doOffscreenTasks(this, before_action_list);
                                GLFX._GLEndFX();
                                GLFX._GLBeginFX(false);
                                doOffscreenTasks(this, offscreen_action_list);
                                GLFX._GLEndFX();
                                GLFX._GLBeginFX(false);
                                doOffscreenTasks(this, after_action_list);
                                GLFX._GLEndFX();
                                monitor.notify();
                        }
                        GL11.glFlush();
                        markFPS();
                } catch (Exception ex) {
                        if (isDebugEnabled()) {
View Full Code Here

                return new Runnable() {
                        @Override
                        public void run() {
                                screenThreadId = Thread.currentThread().getId();
                                try {
                                        final Monitor monitor0 = vSynch;
                                        synchronized (monitor0) {
                                                rendering = true;
                                                if (isDisplayable() && (getState() == State.RUNNING)) {
                                                        if (!Display.isCreated()) {
                                                                if (!isFullscreen()) {
                                                                        Display.setParent(RenderingSceneGL.this);
                                                                }
                                                                Display.create(_GL_pixFormat);
                                                                initGL();
                                                        }
                                                        /* Disable LWJGL input overlay, if Swing is available and not in fullscreen mode
                                                         */
                                                        if (!isKeyboardDisabled() && isUseLWJGLKeyboardAndMouseEnabled() && !Keyboard.isCreated()) {
                                                                Keyboard.create();
                                                        } else if (isKeyboardDisabled() || !isUseLWJGLKeyboardAndMouseEnabled()) {
                                                                Keyboard.destroy();
                                                        }
                                                        if (!isMouseDisabled() && isUseLWJGLKeyboardAndMouseEnabled() && !Mouse.isCreated()) {
                                                                Mouse.create();
                                                        } else if (isMouseDisabled() || !isUseLWJGLKeyboardAndMouseEnabled()) {
                                                                Mouse.destroy();
                                                        }
                                                        Display.makeCurrent();
                                                        Display.processMessages();
                                                        paintGL();
                                                        Display.update(false);
                                                        /**
                                                         * if the
                                                         * gameactionlayer did
                                                         * not process them
                                                         */
                                                        processlLWJGLInput();
                                                }
                                        }
                                } catch (Exception ex) {
                                        if (isDebugActivityEnabled()) {
                                                ex.printStackTrace();
                                        }
                                } finally {
                                        final Monitor monitor1 = vSynch;
                                        synchronized (monitor1) {
                                                rendering = false;
                                                if (Display.isCreated() && Display.isCloseRequested()) {
                                                        stopRendering();
                                                }
                                                monitor1.notifyAll();
                                        }
                                }
                        }
                };
        }
View Full Code Here

        this.keyEvents = Collections.synchronizedMap(_keyEvents = keyEvents);
        highestKeysSequence = highestKeysSequence(this.keyEvents);
        highestKeysSequenceTiming = highestKeysSequenceTiming(this.keyEvents);
        /** rounding 9 ms of dispatching (about HDD average speed)*/
        resetKeyEventsMaps((int) Math.round(highestKeysSequenceTiming / 9.));
        setGroupMonitor(new Monitor(), new Monitor(), new Monitor(), new Monitor(),new Monitor());
    }
View Full Code Here

    @Override
    public boolean dispatchKeyEvent(KeyEvent e) {
        boolean interrupt_ = false;
        boolean b = false;
        try {
            final Monitor monitor = processMonitor;
            synchronized (monitor) {
                while (processing) {
                    monitor.wait();
                }
                monitor.notify();
                dispatching = true;
                long now = e.getWhen();
                if (hasAttribute("player") ? isPlayerKeycode(e) : true) {
                    /* manage key pression time*/
                    switch (e.getID()) {
                        case KeyEvent.KEY_PRESSED:
                            sendKeyEventWrapperPressed(new KeyEventWrapper(now, e.getKeyCode(), KeyEvent.KEY_PRESSED), now);
                            break;
                        case KeyEvent.KEY_RELEASED:
                            sendKeyEventWrapperReleased(new KeyEventWrapper(now, e.getKeyCode(), KeyEvent.KEY_RELEASED), now);
                            break;
                        default:
                            break;
                    }
                    b = true;
                }
            }
        } catch (InterruptedException ex) {
            if (isDebugEnabled()) {
                ex.printStackTrace();
            }
            interrupt_ = true;
        } finally {
            final Monitor monitor = dispatchMonitor;
            synchronized (monitor) {
                dispatching = false;
                monitor.notifyAll();
            }
            if (interrupt_) {
                return false;
            }
            return b;
View Full Code Here

            Player.id player = attributes.containsKey("player") ? (Player.id) attributes.get("player") : Player.id.ONE;
            getRenderingScene().getCtrlHDR().proceedGamePadEvents(gamePad, obs, player);
        }
        String nextAnimName = null;
        try {
            final Monitor monitor0 = dispatchMonitor;
            synchronized (monitor0) {
                while (dispatching) {
                    monitor0.wait();
                }
                monitor0.notify();
                processing = true;
                if ((!isLWJGLAccel() && isLoaded()) || (isLWJGLAccel() && GLisLoaded())) {
                    /* match animation troughout keys sequences*/
                    long now = System.currentTimeMillis();
                    SortedMap<Long, KeyEventWrapper> filter = filterKeysSequence(threadedEventsSequence, now);
                    threadedEventsSequence.clear();
                    if (isDebugEnabled()) {
                        System.out.println(JXAenvUtils.log("current key input filter @ " + now + " #### " + new KeyEventWrapper(new Vector<KeyEventWrapper>(filter.values())), JXAenvUtils.LVL.APP_NOT));
                    }
                    KeyEventWrapper match = processMatcher(filter);
                    nextAnimName = keyEvents.get(match);
                    if (getPlayerStatus() == Animation.PLAYING) {
                        if (animName instanceof String && nextAnimName instanceof String) {
                            if (!animName.equals(nextAnimName) && !nextAnimName.startsWith(animName)) {
                                if (isDebugEnabled()) {
                                    System.out.println(Model.class.getName() + " is playing " + animName + " matched keyEvent " + nextAnimName + " is ignored.");
                                }
                                nextAnimName = null;
                            }
                        }
                    }
                    if (isDebugEnabled()) {
                        System.out.println(JXAenvUtils.log("next anim " + nextAnimName, JXAenvUtils.LVL.APP_NOT));
                    }
                }
            }
        } catch (InterruptedException e) {
            if (isDebugEnabled()) {
                e.printStackTrace();
            }
        } finally {
            final Monitor monitor0 = processMonitor;
            synchronized (monitor0) {
                processing = false;
                monitor0.notifyAll();
            }
            if (nextAnimName instanceof String) {
                if (isLWJGLAccel()) {
                    GLanim(nextAnimName, frameRate, false);
                } else {
View Full Code Here

        frames = Animation._GLgetSpritesHashes(anim.hashCode());
        loadProgress(0, frames.size() - 1);
        /*
         * frames = Collections.synchronizedSortedMap(new TreeMap<Integer, Integer>());
         */
        imageSynch = new Monitor();
        animator = anim.getPosition();
        length = anim.length;
        statusID = anim.getState();
        start = 0;
        NEXT = anim.NEXT;
View Full Code Here

TOP

Related Classes of net.sf.jiga.xtended.kernel.Monitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.