Search in sources :

Example 1 with Embedded

use of org.sirix.gui.view.sunburst.SunburstView.Embedded in project sirix by sirixdb.

the class SunburstControl method keyReleased.

/**
 * Is getting called from processings keyRealeased-method and implements it.
 *
 * @see processing.core.PApplet#keyReleased()
 */
@Override
public void keyReleased() {
    if (!mSunburstGUI.mXPathField.isActive() && !mSunburstGUI.mCtrl.isOpen()) {
        switch(mSunburstGUI.mParent.key) {
            case 'r':
            case 'R':
                mSunburstGUI.mParent.frameRate(35);
                mSunburstGUI.mRad = 0;
                mSunburstGUI.resetZoom();
                mSunburstGUI.mZoomPanReset = true;
                break;
            case 's':
            case 'S':
                // Save PNG.
                mSunburstGUI.mParent.saveFrame(ViewUtilities.SAVEPATH + ViewUtilities.timestamp() + "_##.png");
                break;
            case 'p':
            case 'P':
                // Save PDF.
                mSunburstGUI.mParent.frameRate(60);
                mSunburstGUI.setSavePDF(true);
                PApplet.println("\n" + "saving to pdf – starting");
                mSunburstGUI.mParent.beginRecord(PConstants.PDF, ViewUtilities.SAVEPATH + ViewUtilities.timestamp() + ".pdf");
                mSunburstGUI.mParent.textMode(PConstants.SHAPE);
                break;
            case 'q':
                // mSunburstGUI.setViewKind(EView.NODIFF);
                ((Embedded) mSunburstGUI.mParent).refreshUpdate();
                break;
            case '\b':
                // Backspace.
                mModel.undo();
                mSunburstGUI.undo();
                final SunburstView view = (SunburstView) ((Embedded) mSunburstGUI.mParent).getView();
                final ViewNotifier notifier = view.getNotifier();
                notifier.getGUI().getReadDB().setKey(mModel.getItem(0).getKey());
                notifyChanges(mModel.subList(0, mModel.getItemsSize()));
                break;
            case '1':
                mSunburstGUI.setMappingMode(1);
                break;
            case '2':
                mSunburstGUI.setMappingMode(2);
                break;
            case '3':
                mSunburstGUI.setMappingMode(3);
                break;
            case 'o':
            case 'O':
                if (mSunburstGUI.mUseDiffView == ViewType.NODIFF) {
                    mSunburstGUI.mUseDiffView.setValue(true);
                    mSunburstGUI.mRevisions = mSunburstGUI.getControlP5().addDropdownList("Compare revision", mSunburstGUI.mParent.width - 250, 100, 100, 120);
                    assert mSunburstGUI.mDb != null;
                    try {
                        for (long i = mSunburstGUI.mDb.getRevisionNumber() + 1, newestRev = mSunburstGUI.mDb.getSession().beginNodeReadTrx().getRevisionNumber(); i <= newestRev; i++) {
                            mSunburstGUI.mRevisions.addItem("Revision " + i, (int) i);
                        }
                    } catch (final SirixException e) {
                        LOGWRAPPER.error(e.getMessage(), e);
                        JOptionPane.showMessageDialog(mSunburstGUI.mParent, this, "Failed to open read transaction: " + e.getMessage(), JOptionPane.ERROR_MESSAGE);
                    }
                }
                break;
            default:
        }
        switch(mSunburstGUI.mParent.key) {
            case '1':
            case '2':
            case '3':
                mSunburstGUI.update(EResetZoomer.YES);
                break;
            case 'm':
            case 'M':
                mSunburstGUI.setShowGUI(mSunburstGUI.getControlP5().getGroup("menu").isOpen());
                mSunburstGUI.setShowGUI(!mSunburstGUI.isShowGUI());
                break;
            default:
        }
        final ControllerGroup<?> menu = mSunburstGUI.getControlP5().getGroup("menu");
        if (mSunburstGUI.isShowGUI()) {
            menu.open();
            mSunburstGUI.getApplet().frameRate(5);
        } else {
            menu.close();
            mSunburstGUI.getApplet().frameRate(40);
        }
        if (mSunburstGUI.mParent.keyCode == PConstants.RIGHT) {
            mSunburstGUI.mRad += 5;
            mSunburstGUI.mRadChanged = true;
        } else if (mSunburstGUI.mParent.keyCode == PConstants.LEFT) {
            mSunburstGUI.mRad -= 5;
            mSunburstGUI.mRadChanged = true;
        }
    }
}
Also used : ViewNotifier(org.sirix.gui.view.ViewNotifier) SirixException(org.sirix.exception.SirixException) Embedded(org.sirix.gui.view.sunburst.SunburstView.Embedded)

Aggregations

SirixException (org.sirix.exception.SirixException)1 ViewNotifier (org.sirix.gui.view.ViewNotifier)1 Embedded (org.sirix.gui.view.sunburst.SunburstView.Embedded)1