Search in sources :

Example 1 with SunburstCompareModel

use of org.sirix.gui.view.sunburst.model.SunburstCompareModel in project sirix by sirixdb.

the class SunburstControl method notifyChanges.

/**
 * Notify other views of changes.
 *
 * @param pItems
 *          the new item list
 */
private void notifyChanges(final List<SunburstItem> pItems) {
    assert pItems != null;
    final SunburstView view = (SunburstView) ((Embedded) mSunburstGUI.mParent).getView();
    final ViewNotifier notifier = view.getNotifier();
    if (mModel instanceof SunburstModel) {
        notifier.update(view, Optional.<VisualItemAxis>absent());
    } else if (mModel instanceof SunburstCompareModel) {
        notifier.update(view, Optional.of(new VisualItemAxis(pItems)));
    }
}
Also used : VisualItemAxis(org.sirix.gui.view.VisualItemAxis) SunburstCompareModel(org.sirix.gui.view.sunburst.model.SunburstCompareModel) ViewNotifier(org.sirix.gui.view.ViewNotifier) SunburstModel(org.sirix.gui.view.sunburst.model.SunburstModel)

Example 2 with SunburstCompareModel

use of org.sirix.gui.view.sunburst.model.SunburstCompareModel in project sirix by sirixdb.

the class ViewUtilities method legend.

/**
 * Legend of a SunburstView.
 *
 * @param pGUI
 *          GUI which provides a SunburstView and therefore extends
 *          {@link AbstractSunburstGUI}
 * @param applet
 *          Processing {@link applet} reference
 */
public static void legend(final AbstractSunburstGUI pGUI, final Model<SunburstContainer, SunburstItem> pModel) {
    final PApplet applet = pGUI.getApplet();
    // applet.translate(0, 0);
    applet.textAlign(PConstants.LEFT, PConstants.TOP);
    applet.strokeWeight(0);
    if (pGUI.isShowArcs()) {
        applet.fill(pGUI.getHueStart(), pGUI.getSaturationStart(), pGUI.getBrightnessStart());
        applet.rect(20f, applet.height - 70f, 50, 17);
        color(pGUI);
        applet.text("-", 78, applet.height - 70f);
        applet.fill(pGUI.getHueEnd(), pGUI.getSaturationEnd(), pGUI.getBrightnessEnd());
        applet.rect(90f, applet.height - 70f, 50, 17);
        color(pGUI);
        if (pModel instanceof SunburstModel) {
            applet.text("text node length", 150f, applet.height - 70f);
        }
        if (pModel instanceof SunburstCompareModel || pModel instanceof SmallmultipleModel) {
            applet.text("text node similarity", 150f, applet.height - 70f);
        }
        applet.fill(0, 0, pGUI.getInnerNodeBrightnessStart());
        applet.rect(20f, applet.height - 50f, 50, 17);
        color(pGUI);
        applet.text("-", 78, applet.height - 50f);
        applet.fill(0, 0, pGUI.getInnerNodeBrightnessEnd());
        applet.rect(90f, applet.height - 50f, 50, 17);
        color(pGUI);
        if (pModel instanceof SunburstModel) {
            applet.text("descendant-or-self count of element nodes", 150f, applet.height - 50f);
        }
        if (pModel instanceof SunburstCompareModel || pModel instanceof SmallmultipleModel) {
            applet.text("element node similarity", 150f, applet.height - 50f);
        }
    }
    if (pGUI.isSavePDF()) {
        applet.translate(applet.width / 2f, applet.height / 2f);
        pGUI.setSavePDF(false);
        applet.endRecord();
        PApplet.println("saving to pdf – done");
    }
}
Also used : SunburstCompareModel(org.sirix.gui.view.sunburst.model.SunburstCompareModel) PApplet(processing.core.PApplet) SmallmultipleModel(org.sirix.gui.view.smallmultiple.SmallmultipleModel) SunburstModel(org.sirix.gui.view.sunburst.model.SunburstModel)

Example 3 with SunburstCompareModel

use of org.sirix.gui.view.sunburst.model.SunburstCompareModel in project sirix by sirixdb.

the class SunburstControl method controlEvent.

@Override
public void controlEvent(final ControlEvent pControlEvent) {
    super.controlEvent(pControlEvent);
    if (pControlEvent.isGroup()) {
        if (pControlEvent.getGroup().getName().equals("Compare revision")) {
            mSunburstGUI.mParent.noLoop();
            mSunburstGUI.mSelectedRev = (int) pControlEvent.getGroup().getValue();
            final int selectedRev = mSunburstGUI.mSelectedRev;
            mModel = new SunburstCompareModel(mSunburstGUI.mParent, mSunburstGUI.mDb);
            mModel.addPropertyChangeListener(mSunburstGUI);
            final SunburstContainer container = new SunburstContainer(mSunburstGUI, mModel);
            if (mSunburstGUI.mUsePruning) {
                container.setPruning(Pruning.DIFF);
            } else {
                container.setPruning(Pruning.NO);
            }
            container.setMoveDetection(mSunburstGUI.mUseMoveDetection);
            mModel.traverseTree(container.setRevision(selectedRev).setModWeight(mSunburstGUI.getModificationWeight()));
            mSunburstGUI.mUseDiffView = ViewType.DIFF;
            mSunburstGUI.mUseDiffView.setValue(true);
            final SunburstView view = (SunburstView) ((Embedded) mSunburstGUI.mParent).getView();
            final ViewNotifier notifier = view.getNotifier();
            mDb.setCompareRevisionNumber(selectedRev);
            notifier.init(view);
        }
    } else if (pControlEvent.isController()) {
        if (pControlEvent.getController() instanceof Toggle) {
            final Toggle toggle = (Toggle) pControlEvent.getController();
            final boolean state = toggle.getState();
            switch(toggle.getId()) {
                case 3:
                    mSunburstGUI.setUseArc(state);
                    break;
                case 4:
                    mSunburstGUI.setFisheye(state);
                    break;
                case 5:
                    if (state) {
                        mRefresh = true;
                    }
                    mSunburstGUI.setUsePruning(state);
                    break;
                case 6:
                    mSunburstGUI.setUseAttribute(state);
                    break;
                case 7:
                    mSunburstGUI.setUseMoveDetection(state);
                    break;
            }
        }
    }
}
Also used : SunburstCompareModel(org.sirix.gui.view.sunburst.model.SunburstCompareModel) ViewNotifier(org.sirix.gui.view.ViewNotifier) Toggle(controlP5.Toggle)

Aggregations

SunburstCompareModel (org.sirix.gui.view.sunburst.model.SunburstCompareModel)3 ViewNotifier (org.sirix.gui.view.ViewNotifier)2 SunburstModel (org.sirix.gui.view.sunburst.model.SunburstModel)2 Toggle (controlP5.Toggle)1 VisualItemAxis (org.sirix.gui.view.VisualItemAxis)1 SmallmultipleModel (org.sirix.gui.view.smallmultiple.SmallmultipleModel)1 PApplet (processing.core.PApplet)1