Search in sources :

Example 1 with SunburstItem

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

the class SmallmultipleModel method processDone.

/**
 * Process the "done" event.
 */
public void processDone() {
    switch(mContainer.getCompare()) {
        case DIFFERENTIAL:
        case INCREMENTAL:
            // Add new items.
            addItems();
            // Done.
            firePropertyChange("done", null, true);
            break;
        case HYBRID:
            if (ECompare.HYBRID.getValue()) {
                ECompare.HYBRID.setValue(false);
                mDiffItems = mItems;
                for (final SunburstItem item : mDiffItems) {
                    item.setGreyState(EGreyState.YES);
                    item.setRevision(mContainer.getOldRevision());
                }
                mContainer.getLock().release();
            } else {
                // Compare lists and grey out.
                compareLists(mItems, mDiffItems);
                mItems = mDiffItems;
                // Adjust dot brightness and saturation.
                firePropertyChange("dotBrightness", null, mDotBrightness);
                // Can be the same as mDotBrightness because both values range from 0 to
                // 100.
                firePropertyChange("saturation", null, mDotBrightness);
                mDotBrightness += 25f;
                // Adapt revision.
                for (int j = 0; j < mCompItems.size(); j++) {
                    final List<SunburstItem> prevItems = mCompItems.get(j).mItems;
                    for (int i = 0; i < mItems.size(); i++) {
                        prevItems.get(i).setRevision(mItems.get(i).getRevision());
                    }
                }
                // Add new items.
                final List<SunburstItem> currItems = new ArrayList<>();
                for (int i = 0; i < mItems.size(); i++) {
                    final SunburstItem newItem = new SunburstItem(mItems.get(i));
                    newItem.update(Draw.UPDATEBUFFER, 2, mParent.g);
                    currItems.add(newItem);
                }
                mCompItems.add(new SunburstListContainer(mLastMaxDepth, mLastOldMaxDepth, currItems, mContainer.getRevision()));
                // Done.
                firePropertyChange("done", null, true);
            }
            mContainer.getLatch().countDown();
            break;
    }
}
Also used : SunburstItem(org.sirix.gui.view.sunburst.SunburstItem) ArrayList(java.util.ArrayList)

Example 2 with SunburstItem

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

the class SmallmultipleModel method compare.

// /**
// * Add {@link SunburstItem}s which have been either changed by {@code
// startangle}/{@code endangle} or
// * have been added.
// */
// private void addDiffItems() {
// compare(mItems, mDiffItems, new AddItems());
// 
// // Add items which are at the end of the list.
// if (mItems.size() > mDiffItems.size()) {
// for (int i = mItems.size(); i < mDiffItems.size();) {
// mDiffItems.add(mItems.get(i));
// }
// }
// }
private void compare(final List<SunburstItem> pFirst, final List<SunburstItem> pSecond, final Function<Indexes> pFunction) {
    assert pFirst != null;
    assert pSecond != null;
    for (int i = 0, j = 0; i < pFirst.size() && j < pSecond.size(); ) {
        final SunburstItem firstItem = pFirst.get(i);
        final SunburstItem secondItem = pSecond.get(j);
        final Indexes indexes = pFunction.apply(firstItem, secondItem, i, j);
        i = indexes.mFirstIndex;
        j = indexes.mSecondIndex;
    }
}
Also used : SunburstItem(org.sirix.gui.view.sunburst.SunburstItem)

Example 3 with SunburstItem

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

the class SmallmultipleModel method addItems.

/**
 * Add new items.
 */
private void addItems() {
    final List<SunburstItem> currItems = new ArrayList<SunburstItem>();
    for (int i = 0; i < mItems.size(); i++) {
        final SunburstItem newItem = new SunburstItem(mItems.get(i));
        newItem.update(Draw.UPDATEBUFFER, 2, mParent.g);
        currItems.add(newItem);
    }
    mCompItems.add(new SunburstListContainer(mLastMaxDepth, mLastOldMaxDepth, currItems, mRevision));
    Collections.sort(mCompItems);
}
Also used : SunburstItem(org.sirix.gui.view.sunburst.SunburstItem) ArrayList(java.util.ArrayList)

Example 4 with SunburstItem

use of org.sirix.gui.view.sunburst.SunburstItem 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 5 with SunburstItem

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

the class SmallmultipleModel method compareLists.

/**
 * Compare two {@link List}s and set {@link GreyState} appropriately as well
 * as the revision to which the {@link SunburstItem}s belong.
 *
 * @param pFirst
 *          first list
 * @param pSecond
 *          second list
 */
private void compareLists(final List<SunburstItem> pFirst, final List<SunburstItem> pSecond) {
    assert pFirst != null;
    assert pSecond != null;
    for (final SunburstItem item : pSecond) {
        if (item.getGreyState() == EGreyState.NO) {
            item.setRevision(item.getRevision() + 1);
        }
    }
    final List<SunburstItem> secondList = new ArrayList<SunburstItem>(pSecond);
    Collections.sort(pFirst);
    Collections.sort(secondList);
    compare(pFirst, secondList, new GreyState());
}
Also used : SunburstItem(org.sirix.gui.view.sunburst.SunburstItem) ArrayList(java.util.ArrayList) EGreyState(org.sirix.gui.view.sunburst.EGreyState)

Aggregations

SunburstItem (org.sirix.gui.view.sunburst.SunburstItem)6 ArrayList (java.util.ArrayList)3 ExecutionException (java.util.concurrent.ExecutionException)1 QNm (org.brackit.xquery.atomic.QNm)1 NodeReadTrx (org.sirix.api.NodeReadTrx)1 DiffType (org.sirix.diff.DiffFactory.DiffType)1 DiffTuple (org.sirix.diff.DiffTuple)1 EGreyState (org.sirix.gui.view.sunburst.EGreyState)1 NodeRelations (org.sirix.gui.view.sunburst.NodeRelations)1 EStructType (org.sirix.gui.view.sunburst.SunburstItem.EStructType)1 PImage (processing.core.PImage)1