Example usage for java.util Vector lastElement

List of usage examples for java.util Vector lastElement

Introduction

In this page you can find the example usage for java.util Vector lastElement.

Prototype

public synchronized E lastElement() 

Source Link

Document

Returns the last component of the vector.

Usage

From source file:icom.jpa.bdk.dao.VersionSeriesToDocumentDAO.java

public void copyObjectState(ManagedObjectProxy obj, Object bdkEntity, Projection proj) {
    //super.copyObjectState(obj, bdkEntity, proj);

    Document bdkDocument = null;//from   w  w w  . j av a 2 s  .c o m
    WikiPage bdkWikiPage = null;

    if (bdkEntity instanceof Document) {
        bdkDocument = (Document) bdkEntity;
    } else {
        bdkWikiPage = (WikiPage) bdkEntity;
    }

    Persistent pojoPersistent = obj.getPojoObject();
    PersistenceContext context = obj.getPersistenceContext();

    if (isPartOfProjection(VersionSeriesInfo.Attributes.versionSeriesCheckedOut.name(), proj)) {
        try {
            Boolean versionSeriesCheckedOut = null;
            if (bdkDocument != null) {
                versionSeriesCheckedOut = bdkDocument.isCheckedOut();
            } else {
                versionSeriesCheckedOut = bdkWikiPage.isCheckedOut();
            }
            assignAttributeValue(pojoPersistent, VersionSeriesInfo.Attributes.versionSeriesCheckedOut.name(),
                    versionSeriesCheckedOut);
        } catch (Exception ex) {
            // ignore
        }
    }

    if (isPartOfProjection(VersionSeriesInfo.Attributes.versionSeriesCheckedOutBy.name(), proj)) {
        try {
            Actor bdkVersionSeriesCheckedOutBy = null;
            if (bdkDocument != null) {
                bdkVersionSeriesCheckedOutBy = bdkDocument.getCheckedOutBy();
            } else {
                bdkVersionSeriesCheckedOutBy = bdkWikiPage.getCheckedOutBy();
            }
            if (bdkVersionSeriesCheckedOutBy != null) {
                ManagedIdentifiableProxy actorObj = getEntityProxy(context, bdkVersionSeriesCheckedOutBy);
                Persistent pojoVersionSeriesCheckedOutBy = actorObj.getPojoIdentifiable();
                assignAttributeValue(pojoPersistent,
                        VersionSeriesInfo.Attributes.versionSeriesCheckedOutBy.name(),
                        pojoVersionSeriesCheckedOutBy);
            }
        } catch (Exception ex) {
            // ignore
        }
    }

    if (isPartOfProjection(VersionSeriesInfo.Attributes.versionSeriesCheckedOutOn.name(), proj)) {
        try {
            try {
                XMLGregorianCalendar bdkCheckedOutOn = null;
                if (bdkDocument != null) {
                    bdkCheckedOutOn = bdkDocument.getCheckedOutOn();
                } else {
                    bdkCheckedOutOn = bdkWikiPage.getCheckedOutOn();
                }
                if (bdkCheckedOutOn != null) {
                    Date versionSeriesCheckedOutOn = bdkCheckedOutOn.toGregorianCalendar().getTime();
                    assignAttributeValue(pojoPersistent,
                            VersionSeriesInfo.Attributes.versionSeriesCheckedOutOn.name(),
                            versionSeriesCheckedOutOn);
                }
            } catch (Exception ex) {
                // ignore
            }
        } catch (Exception ex) {
            // ignore
        }
    }

    if (isPartOfProjection(VersionSeriesInfo.Attributes.versionSeriesCheckoutComment.name(), proj)) {
        try {
            String versionSeriesCheckoutComment = null;
            if (bdkDocument != null) {
                versionSeriesCheckoutComment = bdkDocument.getCheckoutComments();
            } else {
                versionSeriesCheckoutComment = bdkWikiPage.getCheckoutComments();
            }
            assignAttributeValue(pojoPersistent,
                    VersionSeriesInfo.Attributes.versionSeriesCheckoutComment.name(),
                    versionSeriesCheckoutComment);
        } catch (Exception ex) {
            // ignore
        }
    }

    if (isPartOfProjection(VersionSeriesInfo.Attributes.totalSize.name(), proj)) {
        try {
            Long totalSize = null;
            if (bdkDocument != null) {
                totalSize = bdkDocument.getTotalSize();
            } else {
                totalSize = bdkWikiPage.getTotalSize();
            }
            assignAttributeValue(pojoPersistent, VersionSeriesInfo.Attributes.totalSize.name(), totalSize);
        } catch (Exception ex) {
            // ignore
        }
    }

    if (isPartOfProjection(VersionSeriesInfo.Attributes.versionHistory.name(), proj)) {
        try {
            Collection<Version> bdkVersionHistory = null;
            if (bdkDocument != null) {
                bdkVersionHistory = bdkDocument.getVersionHistories();
            } else {
                bdkVersionHistory = bdkWikiPage.getVersionHistories();
            }
            Vector<Persistent> v = new Vector<Persistent>(bdkVersionHistory.size());
            if (bdkVersionHistory != null) {
                for (Version bdkVersion : bdkVersionHistory) {
                    ManagedIdentifiableProxy childObj = getEntityProxy(context, bdkVersion);
                    v.add(childObj.getPojoIdentifiable());
                }
            }
            assignAttributeValue(pojoPersistent, VersionSeriesInfo.Attributes.versionHistory.name(), v);
            assignAttributeValue(pojoPersistent, VersionSeriesInfo.Attributes.latestVersion.name(),
                    v.lastElement());
        } catch (Exception ex) {
            // ignore
        }
    }

    Object bdkLatestVersionableInHistory = null;
    if (isPartOfProjection(VersionSeriesInfo.Attributes.versionableHistory.name(), proj)) {
        try {
            Collection<Object> bdkVersionableHistory = null;
            if (bdkDocument != null) {
                bdkVersionableHistory = bdkDocument.getVersionableHistories();
            } else {
                bdkVersionableHistory = bdkWikiPage.getVersionableHistories();
            }
            Vector<Persistent> pojoVersionableHistory = new Vector<Persistent>(bdkVersionableHistory.size());
            if (bdkVersionableHistory != null) {
                for (Object bdkVersionable : bdkVersionableHistory) {
                    ManagedIdentifiableProxy childObj = getEntityProxy(context, bdkVersionable);
                    pojoVersionableHistory.add(childObj.getPojoIdentifiable());
                    bdkLatestVersionableInHistory = bdkVersionable;
                }
            }
            assignAttributeValue(pojoPersistent, VersionSeriesInfo.Attributes.versionableHistory.name(),
                    pojoVersionableHistory);
        } catch (Exception ex) {
            // ignore
        }
    }

    if (isPartOfProjection(VersionSeriesInfo.Attributes.latestVersionedCopy.name(), proj)) {
        try {
            Persistent pojoLatestVersionedCopy = null;
            Object bdkRepresentativeVersionable = null;
            if (bdkDocument != null) {
                bdkRepresentativeVersionable = bdkDocument.getRepresentativeVersionable();
            } else {
                bdkRepresentativeVersionable = bdkWikiPage.getRepresentativeVersionable();
            }
            if (bdkRepresentativeVersionable != null) {
                if (bdkLatestVersionableInHistory != null) {
                    String bdkRepresentativeVersionableId = null;
                    String bdkLatestVersionableInHistoryId = null;
                    if (bdkRepresentativeVersionable instanceof Document
                            || bdkRepresentativeVersionable instanceof WikiPage) {
                        bdkRepresentativeVersionableId = ((Artifact) bdkRepresentativeVersionable).getCollabId()
                                .getId();
                    }
                    if (bdkLatestVersionableInHistory instanceof Document
                            || bdkLatestVersionableInHistory instanceof WikiPage) {
                        bdkLatestVersionableInHistoryId = ((Artifact) bdkLatestVersionableInHistory)
                                .getCollabId().getId();
                    }
                    if (bdkRepresentativeVersionableId.equals(bdkLatestVersionableInHistoryId)) {
                        ManagedIdentifiableProxy childObj = getEntityProxy(context,
                                bdkRepresentativeVersionable);
                        pojoLatestVersionedCopy = childObj.getPojoIdentifiable();
                    } else {
                        ManagedIdentifiableProxy childObj = getEntityProxy(context,
                                bdkLatestVersionableInHistory);
                        pojoLatestVersionedCopy = childObj.getPojoIdentifiable();
                    }
                }
            }
            assignAttributeValue(pojoPersistent, VersionSeriesInfo.Attributes.latestVersionedCopy.name(),
                    pojoLatestVersionedCopy);
        } catch (Exception ex) {
            // ignore
        }
    }

    if (isPartOfProjection(VersionSeriesInfo.Attributes.privateWorkingCopy.name(), proj)) {
        try {
            Persistent pojoPrivateWorkingCopy = null;
            Object bdkRepresentativeVersionable = null;
            if (bdkDocument != null) {
                bdkRepresentativeVersionable = bdkDocument.getRepresentativeVersionable();
            } else {
                bdkRepresentativeVersionable = bdkWikiPage.getRepresentativeVersionable();
            }
            if (bdkRepresentativeVersionable != null) {
                if (bdkLatestVersionableInHistory != null) {
                    String bdkRepresentativeVersionableId = null;
                    String bdkLatestVersionableInHistoryId = null;
                    if (bdkRepresentativeVersionable instanceof Document
                            || bdkRepresentativeVersionable instanceof WikiPage) {
                        bdkRepresentativeVersionableId = ((Artifact) bdkRepresentativeVersionable).getCollabId()
                                .getId();
                    }
                    if (bdkLatestVersionableInHistory instanceof Document
                            || bdkLatestVersionableInHistory instanceof WikiPage) {
                        bdkLatestVersionableInHistoryId = ((Artifact) bdkLatestVersionableInHistory)
                                .getCollabId().getId();
                    }
                    if (!bdkRepresentativeVersionableId.equals(bdkLatestVersionableInHistoryId)) {
                        ManagedIdentifiableProxy childObj = getEntityProxy(context,
                                bdkRepresentativeVersionable);
                        pojoPrivateWorkingCopy = childObj.getPojoIdentifiable();
                    }
                }
            }
            assignAttributeValue(pojoPersistent, VersionSeriesInfo.Attributes.privateWorkingCopy.name(),
                    pojoPrivateWorkingCopy);
        } catch (Exception ex) {
            // ignore
        }
    }

    if (isPartOfProjection(VersionSeriesInfo.Attributes.representativeCopy.name(), proj)) {
        try {
            Persistent pojoRepresentativeCopy = null;
            Object bdkFamilyVersionable = null;
            if (bdkDocument != null) {
                bdkFamilyVersionable = bdkDocument.getParentFamily();
            } else {
                bdkFamilyVersionable = bdkWikiPage.getParentFamily();
            }
            if (bdkFamilyVersionable != null) {
                ManagedIdentifiableProxy childObj = getEntityProxy(context, bdkFamilyVersionable);
                pojoRepresentativeCopy = childObj.getPojoIdentifiable();
            }
            assignAttributeValue(pojoPersistent, VersionSeriesInfo.Attributes.representativeCopy.name(),
                    pojoRepresentativeCopy);
        } catch (Exception ex) {
            // ignore
        }
    }

}

From source file:com.owncloud.android.ui.fragment.contactsbackup.ContactsBackupFragment.java

public void openDate(@Nullable Date savedDate) {
    final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();

    String backupFolderString = getResources().getString(R.string.contacts_backup_folder)
            + OCFile.PATH_SEPARATOR;//from  ww  w  . j  a  v  a 2 s .  c om
    OCFile backupFolder = contactsPreferenceActivity.getStorageManager().getFileByPath(backupFolderString);

    Vector<OCFile> backupFiles = contactsPreferenceActivity.getStorageManager().getFolderContent(backupFolder,
            false);

    Collections.sort(backupFiles, new Comparator<OCFile>() {
        @Override
        public int compare(OCFile o1, OCFile o2) {
            if (o1.getModificationTimestamp() == o2.getModificationTimestamp()) {
                return 0;
            }

            if (o1.getModificationTimestamp() > o2.getModificationTimestamp()) {
                return 1;
            } else {
                return -1;
            }
        }
    });

    Calendar cal = Calendar.getInstance();
    int year;
    int month;
    int day;

    if (savedDate == null) {
        year = cal.get(Calendar.YEAR);
        month = cal.get(Calendar.MONTH) + 1;
        day = cal.get(Calendar.DAY_OF_MONTH);
    } else {
        year = savedDate.getYear();
        month = savedDate.getMonth();
        day = savedDate.getDay();
    }

    if (backupFiles.size() > 0 && backupFiles.lastElement() != null) {
        datePickerDialog = new DatePickerDialog(contactsPreferenceActivity, this, year, month, day);
        datePickerDialog.getDatePicker().setMaxDate(backupFiles.lastElement().getModificationTimestamp());
        datePickerDialog.getDatePicker().setMinDate(backupFiles.firstElement().getModificationTimestamp());

        datePickerDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                selectedDate = null;
            }
        });

        datePickerDialog.show();
    } else {
        Toast.makeText(contactsPreferenceActivity, R.string.contacts_preferences_something_strange_happened,
                Toast.LENGTH_SHORT).show();
    }
}

From source file:net.alastairwyse.methodinvocationremoting.RemoteReceiverDecompressor.java

/**
 * Decompresses a string./*from w  w  w  .  ja  v a2s  .  c o  m*/
 * @param inputString  The string to decompress.
 * @return             The decompressed string.
 */
private String DecompressString(String inputString) throws Exception {
    /* //[BEGIN_METRICS]
    metricLogger.Begin(new StringDecompressTime());
    //[END_METRICS] */

    decompressing = true;

    Vector<byte[]> readBuffers = new Vector<byte[]>();
    int currentReadBufferPosition = 0;
    String returnString = "";

    // If the inputted string is blank, then skip decompression and return a blank string.  The C# RemoteSenderCompressor class will compress a blank string as blank.
    if (inputString.equals("") == false) {
        byte[] encodedBytes = Base64.decodeBase64(inputString);
        try (ByteArrayInputStream decompressedStringStream = new ByteArrayInputStream(encodedBytes);
                GZIPInputStream decompressor = new GZIPInputStream(decompressedStringStream)) {
            int bytesRead = 0;
            while (bytesRead != -1) {
                // If the vector of buffers is empty, or the read position in the current (last) buffer is at the end of the buffer, then create a new read buffer
                if ((readBuffers.size() == 0) || (currentReadBufferPosition == decompressionBufferSize)) {
                    readBuffers.add(new byte[decompressionBufferSize]);
                    currentReadBufferPosition = 0;

                    /* //[BEGIN_METRICS]
                    metricLogger.Increment(new RemoteReceiverDecompressorReadBufferCreated());
                    //[END_METRICS] */
                }
                currentReadBufferPosition = currentReadBufferPosition + bytesRead;
                bytesRead = decompressor.read(readBuffers.lastElement(), currentReadBufferPosition,
                        decompressionBufferSize - currentReadBufferPosition);
            }

            // Create decompressed byte array with size as buffer size times the number of buffers (except the last buffer), plus the position within the last buffer
            byte[] decompressedBytes = new byte[((readBuffers.size() - 1) * decompressionBufferSize)
                    + currentReadBufferPosition];
            // Copy the contents of the read buffers into the decompressed byte array
            int decompressedBytesPosition = 0;
            for (byte[] currentReadBuffer : readBuffers) {
                if (currentReadBuffer != readBuffers.lastElement()) {
                    System.arraycopy(currentReadBuffer, 0, decompressedBytes, decompressedBytesPosition,
                            decompressionBufferSize);
                    decompressedBytesPosition = decompressedBytesPosition + decompressionBufferSize;
                } else {
                    System.arraycopy(currentReadBuffer, 0, decompressedBytes, decompressedBytesPosition,
                            currentReadBufferPosition);
                }
            }

            returnString = new String(decompressedBytes, stringEncodingCharset);
        } catch (Exception e) {
            /* //[BEGIN_METRICS]
            metricLogger.CancelBegin(new StringDecompressTime());
            //[END_METRICS] */
            throw new Exception("Error decompressing message.", e);
        }
    }

    /* //[BEGIN_METRICS]
    metricLogger.End(new StringDecompressTime());
    metricLogger.Increment(new StringDecompressed());
    //[END_METRICS] */
    /* //[BEGIN_LOGGING]
    loggingUtilities.LogDecompressedString(this, returnString);
    //[END_LOGGING] */

    decompressing = false;
    return returnString;
}

From source file:edu.umn.cs.spatialHadoop.nasa.StockQuadTree.java

/**
 * Perform a selection query that retrieves all points in the given range.
 * The range is specified in the two-dimensional array positions. 
 * @param in//from   w w w.  j av a 2  s . c  o  m
 * @param query_mbr
 * @return
 * @throws IOException
 */
public static Node aggregateQuery(FSDataInputStream in, Rectangle query_mbr) throws IOException {
    long treeStartPosition = in.getPos();
    Node result = new Node();
    int numOfSelectedRecords = 0;
    int resolution = in.readInt();
    short fillValue = in.readShort();
    int cardinality = in.readInt();
    final Vector<Integer> selectedNodesPos = new Vector<Integer>();
    final Vector<Integer> selectedStarts = new Vector<Integer>();
    final Vector<Integer> selectedEnds = new Vector<Integer>();
    StockQuadTree stockQuadTree = getOrCreateStockQuadTree(resolution);
    // Nodes to be searched. Contains node positions in the array of nodes
    Stack<Integer> nodes_2b_searched = new Stack<Integer>();
    nodes_2b_searched.add(0); // Root node (ID=1)
    Rectangle node_mbr = new Rectangle();
    while (!nodes_2b_searched.isEmpty()) {
        int node_pos = nodes_2b_searched.pop();
        stockQuadTree.getNodeMBR(node_pos, node_mbr);
        if (query_mbr.contains(node_mbr)) {
            // Add this node to the selection list and stop this branch
            selectedNodesPos.add(node_pos);
        } else if (query_mbr.intersects(node_mbr)) {
            int first_child_id = stockQuadTree.nodesID[node_pos] * 4 + 0;
            int first_child_pos = Arrays.binarySearch(stockQuadTree.nodesID, first_child_id);
            if (first_child_pos < 0) {
                // No children. Hit a leaf node
                // Scan and add matching points only
                java.awt.Point record_coords = new Point();
                for (int record_pos = stockQuadTree.nodesStartPosition[node_pos]; record_pos < stockQuadTree.nodesEndPosition[node_pos]; record_pos++) {
                    stockQuadTree.getRecordCoords(record_pos, record_coords);
                    if (query_mbr.contains(record_coords)) {
                        // matched a record.
                        if (!selectedEnds.isEmpty() && selectedEnds.lastElement() == record_pos) {
                            // Merge with an adjacent range
                            selectedEnds.set(selectedEnds.size() - 1, record_pos + 1);
                        } else {
                            // Add a new range of unit width
                            selectedStarts.add(record_pos);
                            selectedEnds.add(record_pos + 1);
                        }
                        numOfSelectedRecords++;
                    }
                }
            } else {
                // Non-leaf node. Add all children to the list of nodes to search
                // Add in reverse order to the stack so that results come in sorted order
                nodes_2b_searched.add(first_child_pos + 3);
                nodes_2b_searched.add(first_child_pos + 2);
                nodes_2b_searched.add(first_child_pos + 1);
                nodes_2b_searched.add(first_child_pos + 0);
            }
        }
    }
    // Result 1: Accumulate all values
    // Sort disk offsets to eliminate backward seeks
    if (!selectedStarts.isEmpty()) {
        LOG.debug("Aggregate query selected " + selectedNodesPos.size() + " nodes and " + numOfSelectedRecords
                + " records");

        final IndexedSortable sortable = new IndexedSortable() {
            @Override
            public int compare(int i, int j) {
                return selectedStarts.get(i) - selectedStarts.get(j);
            }

            @Override
            public void swap(int i, int j) {
                int temp = selectedStarts.get(i);
                selectedStarts.set(i, selectedStarts.get(j));
                selectedStarts.set(j, temp);

                temp = selectedEnds.get(i);
                selectedEnds.set(i, selectedEnds.get(j));
                selectedEnds.set(j, temp);
            }
        };
        new QuickSort().sort(sortable, 0, selectedStarts.size());

        long dataStartPosition = getValuesStartOffset(cardinality);
        Point resultCoords = new Point();
        // Return all values in the selected ranges
        for (int iRange = 0; iRange < selectedStarts.size(); iRange++) {
            int treeStart = selectedStarts.get(iRange);
            int treeEnd = selectedEnds.get(iRange);
            long startPosition = dataStartPosition + selectedStarts.get(iRange) * cardinality * 2;
            in.seek(startPosition);
            for (int treePos = treeStart; treePos < treeEnd; treePos++) {
                // Retrieve the coords for the point at treePos
                stockQuadTree.getRecordCoords(treePos, resultCoords);
                // Read all entries at current position
                for (int iValue = 0; iValue < cardinality; iValue++) {
                    short value = in.readShort();
                    if (value != fillValue)
                        result.accumulate(value);
                }
            }
        }

    }

    // Result 2: Accumulate all nodes
    if (!selectedNodesPos.isEmpty()) {
        long nodesStartPosition = treeStartPosition + getNodesStartOffset(resolution, cardinality);
        // Sort node positions to eliminate backward seeks
        IndexedSortable nodeSortable = new IndexedSortable() {
            @Override
            public int compare(int i, int j) {
                return selectedNodesPos.get(i) - selectedNodesPos.get(j);
            }

            @Override
            public void swap(int i, int j) {
                int temp = selectedNodesPos.get(i);
                selectedNodesPos.set(i, selectedNodesPos.get(j));
                selectedNodesPos.set(j, temp);
            }
        };
        new QuickSort().sort(nodeSortable, 0, selectedNodesPos.size());

        Node selectedNode = new Node();
        for (int node_pos : selectedNodesPos) {
            long nodePosition = nodesStartPosition + node_pos * NodeSize;
            in.seek(nodePosition);
            selectedNode.readFields(in);
            result.accumulate(selectedNode);
        }
    }
    return result;
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.reporting.AnnotationReportCanvas.java

private void placeStructures(Vector<AnnotationObject> annotations, boolean init) {

    // get starting point
    double y = thePlot.getRangeAxis().getRange().getUpperBound();
    double cur_x = thePlot.getDomainAxis().getRange().getLowerBound();

    double all_width = 0.;
    for (AnnotationObject a : annotations) {
        if (a.hasAnnotations())
            all_width += screenToDataX(rectangles_complete.get(a).width);
    }//from   w ww.  jav a  2  s  .  c  o m

    double min_pp_x = annotations.firstElement().getPeakPoint().getX();
    double max_pp_x = annotations.lastElement().getPeakPoint().getX();
    double center_pp_x = (max_pp_x + min_pp_x) / 2;

    cur_x = Math.max(cur_x, center_pp_x - all_width / 2);

    // place annotations
    for (AnnotationObject a : annotations) {
        Point2D pp = a.getPeakPoint();
        if (a.hasAnnotations()) {
            double cur_width = screenToDataX(rectangles_complete.get(a).width);
            double x = cur_x + cur_width / 2.;
            theDocument.getAnchor(a).setLocation(x, y);
            theDocument.getControlPoints().put(a,
                    theDocument.computeControlPoint(new Point2D.Double(x, y), pp));

            cur_x += cur_width;
        } else {
            theDocument.getAnchor(a).setLocation(pp.getX(), pp.getY());
            theDocument.getControlPoints().put(a, theDocument.computeControlPoint(pp, pp));
        }
    }

    // refine control points
    for (int i = 0; i < annotations.size(); i++) {
        AnnotationObject ai = annotations.get(i);
        Point2D aai = theDocument.getAnchor(ai);
        Point2D cpi = theDocument.getControlPoint(ai);

        if (aai.getX() < cpi.getX()) {
            for (int l = i + 1; l < annotations.size(); l++) {
                AnnotationObject al = annotations.get(l);
                Point2D aal = theDocument.getAnchor(al);
                Point2D cpl = theDocument.getControlPoint(al);

                if (aal.getX() > cpi.getX())
                    break;
                if (cpl.getY() < cpi.getY()) {
                    cpl.setLocation(cpl.getX(), cpi.getY());
                    ai = al;
                    aai = aal;
                    cpi = cpl;
                } else
                    break;
            }
        } else {
            for (int l = i - 1; l >= 0; l--) {
                AnnotationObject al = annotations.get(l);
                Point2D aal = theDocument.getAnchor(al);
                Point2D cpl = theDocument.getControlPoint(al);

                if (aal.getX() < cpi.getX())
                    break;
                if (cpl.getY() < cpi.getY()) {
                    cpl.setLocation(cpl.getX(), cpi.getY());
                    ai = al;
                    aai = aal;
                    cpi = cpl;
                } else
                    break;
            }
        }
    }

    // fire events
    if (init)
        theDocument.fireDocumentInit();
    else
        theDocument.fireDocumentChanged();
}

From source file:JavaViewer.java

/**
 * Event.detail line start offset (input) Event.text line text (input)
 * LineStyleEvent.styles Enumeration of StyleRanges, need to be in order.
 * (output) LineStyleEvent.background line background color (output)
 *//*  w  ww  . ja  va  2s.  c om*/
public void lineGetStyle(LineStyleEvent event) {
    Vector styles = new Vector();
    int token;
    StyleRange lastStyle;
    // If the line is part of a block comment, create one style for the
    // entire line.
    if (inBlockComment(event.lineOffset, event.lineOffset + event.lineText.length())) {
        styles.addElement(new StyleRange(event.lineOffset, event.lineText.length(), getColor(COMMENT), null));
        event.styles = new StyleRange[styles.size()];
        styles.copyInto(event.styles);
        return;
    }
    Color defaultFgColor = ((Control) event.widget).getForeground();
    scanner.setRange(event.lineText);
    token = scanner.nextToken();
    while (token != EOF) {
        if (token == OTHER) {
            // do nothing for non-colored tokens
        } else if (token != WHITE) {
            Color color = getColor(token);
            // Only create a style if the token color is different than the
            // widget's default foreground color and the token's style is
            // not
            // bold. Keywords are bolded.
            if ((!color.equals(defaultFgColor)) || (token == KEY)) {
                StyleRange style = new StyleRange(scanner.getStartOffset() + event.lineOffset,
                        scanner.getLength(), color, null);
                if (token == KEY) {
                    style.fontStyle = SWT.BOLD;
                }
                if (styles.isEmpty()) {
                    styles.addElement(style);
                } else {
                    // Merge similar styles. Doing so will improve
                    // performance.
                    lastStyle = (StyleRange) styles.lastElement();
                    if (lastStyle.similarTo(style) && (lastStyle.start + lastStyle.length == style.start)) {
                        lastStyle.length += style.length;
                    } else {
                        styles.addElement(style);
                    }
                }
            }
        } else if ((!styles.isEmpty())
                && ((lastStyle = (StyleRange) styles.lastElement()).fontStyle == SWT.BOLD)) {
            int start = scanner.getStartOffset() + event.lineOffset;
            lastStyle = (StyleRange) styles.lastElement();
            // A font style of SWT.BOLD implies that the last style
            // represents a java keyword.
            if (lastStyle.start + lastStyle.length == start) {
                // Have the white space take on the style before it to
                // minimize the number of style ranges created and the
                // number of font style changes during rendering.
                lastStyle.length += scanner.getLength();
            }
        }
        token = scanner.nextToken();
    }
    event.styles = new StyleRange[styles.size()];
    styles.copyInto(event.styles);
}

From source file:org.apache.jetspeed.modules.actions.portlets.PsmlManagerAction.java

/**
 * Creates profile locator from a given path in the format:
 *
 *   user/<name>/<mediaType>/<language>/<country>/<page>/
 *
 *   group/ ""/*from   ww w.j  ava  2 s.co  m*/
 *   role/  ""
 *
 * @param path The formatted profiler path string.
 * @param path   fully qualified .psml file name
 * @return profile locator
 */
private ProfileLocator mapFileToLocator(String path) throws Exception {
    if (logger.isDebugEnabled()) {
        logger.debug("PsmlUpdateAction.createFromPath: processing path = " + path);
    }
    ProfileLocator result = Profiler.createLocator();

    // Tokenize the file path into elements
    StringTokenizer tok = new StringTokenizer(path, File.separator);

    // Load path elements into a vector for random access
    Vector tokens = new Vector();
    while (tok.hasMoreTokens()) {
        tokens.add(tok.nextToken());
    }

    // Assume that 1st element is the profile type (user|role|group) and 2nd is the name
    if (tokens.size() > 1) {
        String type = (String) tokens.elementAt(0);
        String name = (String) tokens.elementAt(1);
        if (type.equals(Profiler.PARAM_USER)) {
            result.setUser(JetspeedSecurity.getUser(name));
        } else if (type.equals(Profiler.PARAM_GROUP)) {
            result.setGroup(JetspeedSecurity.getGroup(name));
        } else if (type.equals(Profiler.PARAM_ROLE)) {
            result.setRole(JetspeedSecurity.getRole(name));
        }
    }

    // Assume that the last element is the page name
    if (tokens.size() > 0) {
        result.setName((String) tokens.lastElement());
    }

    // Based on the number of path elements set the other profile attributes
    switch (tokens.size()) {
    case 3: // user|role|group/name/page.psml
        break;
    case 4: // user|role|group/name/media-type/page.psml
        result.setMediaType((String) tokens.elementAt(2));
        break;
    case 5: // user|role|group/name/media-type/language/page.psml
        result.setMediaType((String) tokens.elementAt(2));
        result.setLanguage((String) tokens.elementAt(3));
        break;
    case 6: // user|role|group/name/media-type/language/country/page.psml
        result.setMediaType((String) tokens.elementAt(2));
        result.setLanguage((String) tokens.elementAt(3));
        result.setCountry((String) tokens.elementAt(4));
        break;
    default:
        throw new Exception(
                "Path must contain 3 to 6 elements: [" + path + "], and the size was: " + tokens.size());
    }

    return result;
}

From source file:edu.ku.brc.specify.conversion.ConvertTaxonHelper.java

/**
 * Converts the taxonomy tree definition from the old taxonomicunittype table to the new table
 * pair: TaxonTreeDef & TaxonTreeDefItems.
 * //  ww w  . j  av a  2  s .  c  o m
 * @param taxonomyTypeId the tree def id in taxonomicunittype
 * @return the TaxonTreeDef object
 * @throws SQLException
 */
public void convertTaxonTreeDefinition(final CollectionInfo colInfo) {
    if (!colInfo.isInUse()) {
        return;
    }

    TaxonTreeDef taxonTreeDef = newTaxonInfoHash.get(colInfo.getTaxonNameId());
    if (taxonTreeDef != null) {
        colInfo.setTaxonTreeDef(taxonTreeDef);
        return;
    }

    Integer oldTaxonRootId = colInfo.getTaxonNameId();
    Integer taxonomyTypeId = colInfo.getTaxonomyTypeId();

    try {
        Statement st = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

        taxonTreeDef = new TaxonTreeDef();
        taxonTreeDef.initialize();

        String sql = "SELECT TaxonomyTypeName, KingdomID FROM taxonomytype WHERE TaxonomyTypeID = "
                + taxonomyTypeId;
        log.debug(sql);
        ResultSet rs = st.executeQuery(sql);
        rs.next();
        String taxonomyTypeName = rs.getString(1);
        int kingdomID = rs.getInt(2);
        rs.close();

        taxonTreeDef.setName(taxonomyTypeName + " taxonomy tree");
        taxonTreeDef.setRemarks("Tree converted from " + oldDBName);
        taxonTreeDef.setFullNameDirection(TreeDefIface.FORWARD);

        sql = String.format(
                "SELECT RankID, RankName, RequiredParentRankID, TaxonomicUnitTypeID FROM taxonomicunittype "
                        + "WHERE TaxonomyTypeID = %d AND (Kingdom = %d  OR RankID = 0) ORDER BY RankID",
                taxonomyTypeId, kingdomID);
        log.debug(sql);
        rs = st.executeQuery(sql);

        Hashtable<Integer, Integer> rankId2TxnUntTypId = new Hashtable<Integer, Integer>();
        int rank;
        String name;
        int requiredRank;

        Vector<TaxonTreeDefItem> items = new Vector<TaxonTreeDefItem>();
        Vector<Integer> enforcedRanks = new Vector<Integer>();

        while (rs.next()) {
            rank = rs.getInt(1);
            name = rs.getString(2);
            requiredRank = rs.getInt(3);

            int taxUnitTypeId = rs.getInt(4);

            if (StringUtils.isEmpty(name) || (rank > 0 && requiredRank == 0)) {
                continue;
            }

            if (rankId2TxnUntTypId.get(rank) != null) {
                String msg = String.format(
                        "Old TreeDef has two of the same Rank %d, throwing it out.\n\nYou must fix this before proceeding.",
                        rank);
                tblWriter.logError(msg);
                log.debug(msg);
                UIRegistry.displayErrorDlg(msg);
                System.exit(0);
            }
            rankId2TxnUntTypId.put(rank, taxUnitTypeId);

            log.debug(rank + "  " + name + "  TaxonomicUnitTypeID: " + taxUnitTypeId);

            TaxonTreeDefItem ttdi = new TaxonTreeDefItem();
            ttdi.initialize();
            ttdi.setName(name);
            ttdi.setFullNameSeparator(" ");
            ttdi.setRankId(rank);
            ttdi.setTreeDef(taxonTreeDef);
            taxonTreeDef.getTreeDefItems().add(ttdi);

            ttdi.setIsInFullName(rank >= TaxonTreeDef.GENUS);

            // setup the parent/child relationship
            if (items.isEmpty()) {
                ttdi.setParent(null);
            } else {
                ttdi.setParent(items.lastElement());
            }
            items.add(ttdi);
            enforcedRanks.add(requiredRank);
        }
        rs.close();

        for (TaxonTreeDefItem i : items) {
            i.setIsEnforced(enforcedRanks.contains(i.getRankId()));
        }

        try {
            Session session = HibernateUtil.getNewSession();
            Transaction trans = session.beginTransaction();
            session.save(taxonTreeDef);
            trans.commit();
            session.close();

        } catch (Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }

        IdMapperMgr idMapperMgr = IdMapperMgr.getInstance();
        IdMapperIFace tutMapper = idMapperMgr.get("TaxonomicUnitType", "TaxonomicUnitTypeID");
        IdMapperIFace taxonomyTypeMapper = idMapperMgr.get("TaxonomyType", "TaxonomyTypeID");

        //tutMapper.reset();

        //if (taxonomyTypeMapper.get(taxonomyTypeId) == null)
        //{
        taxonomyTypeMapper.put(taxonomyTypeId, taxonTreeDef.getId());
        //}

        for (TaxonTreeDefItem ttdi : taxonTreeDef.getTreeDefItems()) {
            int ttdiId = rankId2TxnUntTypId.get(ttdi.getRankId());
            log.debug("Mapping " + ttdiId + " -> " + ttdi.getId() + "  RankId: " + ttdi.getRankId());
            tutMapper.put(ttdiId, ttdi.getId());
        }

        newTaxonInfoHash.put(oldTaxonRootId, taxonTreeDef);

        CollectionInfo ci = getCIByTaxonTypeId(taxonomyTypeId);
        ci.setTaxonTreeDef(taxonTreeDef);

        taxonTreeDefHash.put(taxonomyTypeId, taxonTreeDef);
        log.debug("Hashing taxonomyTypeId: " + taxonomyTypeId + " ->  taxonTreeDefId:" + taxonTreeDef.getId());

    } catch (SQLException ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }
}

From source file:com.owncloud.android.ui.activity.ContactsPreferenceActivity.java

public void openDate(View v) {
    String backupFolderString = getResources().getString(R.string.contacts_backup_folder)
            + OCFile.PATH_SEPARATOR;//from w  w w  . j a  va  2  s. c  om
    OCFile backupFolder = getStorageManager().getFileByPath(backupFolderString);

    Vector<OCFile> backupFiles = getStorageManager().getFolderContent(backupFolder, false);

    Collections.sort(backupFiles, new Comparator<OCFile>() {
        @Override
        public int compare(OCFile o1, OCFile o2) {
            if (o1.getModificationTimestamp() == o2.getModificationTimestamp()) {
                return 0;
            }

            if (o1.getModificationTimestamp() > o2.getModificationTimestamp()) {
                return 1;
            } else {
                return -1;
            }
        }
    });

    Calendar cal = Calendar.getInstance();
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH) + 1;
    int day = cal.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
            String backupFolderString = getResources().getString(R.string.contacts_backup_folder)
                    + OCFile.PATH_SEPARATOR;
            OCFile backupFolder = getStorageManager().getFileByPath(backupFolderString);
            Vector<OCFile> backupFiles = getStorageManager().getFolderContent(backupFolder, false);

            // find file with modification with date and time between 00:00 and 23:59
            // if more than one file exists, take oldest
            Calendar date = Calendar.getInstance();
            date.set(year, month, dayOfMonth);

            // start
            date.set(Calendar.HOUR, 0);
            date.set(Calendar.MINUTE, 0);
            date.set(Calendar.SECOND, 1);
            date.set(Calendar.MILLISECOND, 0);
            date.set(Calendar.AM_PM, Calendar.AM);
            Long start = date.getTimeInMillis();

            // end
            date.set(Calendar.HOUR, 23);
            date.set(Calendar.MINUTE, 59);
            date.set(Calendar.SECOND, 59);
            Long end = date.getTimeInMillis();

            OCFile backupToRestore = null;

            for (OCFile file : backupFiles) {
                if (start < file.getModificationTimestamp() && end > file.getModificationTimestamp()) {
                    if (backupToRestore == null) {
                        backupToRestore = file;
                    } else if (backupToRestore.getModificationTimestamp() < file.getModificationTimestamp()) {
                        backupToRestore = file;
                    }
                }
            }

            if (backupToRestore != null) {
                Fragment contactListFragment = ContactListFragment.newInstance(backupToRestore, getAccount());

                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.replace(R.id.contacts_linear_layout, contactListFragment);
                transaction.commit();
            } else {
                Toast.makeText(ContactsPreferenceActivity.this, R.string.contacts_preferences_no_file_found,
                        Toast.LENGTH_SHORT).show();
            }
        }
    };

    DatePickerDialog datePickerDialog = new DatePickerDialog(this, dateSetListener, year, month, day);
    datePickerDialog.getDatePicker().setMaxDate(backupFiles.lastElement().getModificationTimestamp());
    datePickerDialog.getDatePicker().setMinDate(backupFiles.firstElement().getModificationTimestamp());

    datePickerDialog.show();
}

From source file:org.earthtime.UPb_Redux.dateInterpretation.WeightedMeanGraphPanel.java

/**
 *
 * @param g2d/*from w  ww  .  ja va2s .com*/
 */
public void paint(Graphics2D g2d) {

    // setup painting parameters
    String fractionSortOrder = "name"; //random, weight, date
    if (getWeightedMeanOptions().containsKey("fractionSortOrder")) {
        fractionSortOrder = getWeightedMeanOptions().get("fractionSortOrder");
    }

    double rangeX = (getMaxX_Display() - getMinX_Display());
    double rangeY = (getMaxY_Display() - getMinY_Display());

    g2d.setClip(getLeftMargin(), getTopMargin(), getGraphWidth(), getGraphHeight());
    RenderingHints rh = g2d.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2d.setRenderingHints(rh);

    // walk the sampleDateInterpretations and produce graphs
    g2d.setPaint(Color.BLACK);
    g2d.setStroke(new BasicStroke(2.0f));
    g2d.setFont(new Font("SansSerif", Font.BOLD, 10));

    double barWidth = 15.0;
    double barGap = 10.0;
    double startSamX = 10.0;
    double saveStartSamX = 0.0;
    double samSpace = 3.0;

    for (int i = 0; i < selectedSampleDateModels.length; i++) {
        for (int j = 1; j < 9; j++) {
            if (selectedSampleDateModels[i][j] instanceof SampleDateModel) {

                final SampleDateModel SAM = ((SampleDateModel) selectedSampleDateModels[i][j]);
                double wMean = SAM.getValue().movePointLeft(6).doubleValue();
                double wMeanOneSigma = SAM.getOneSigmaAbs().movePointLeft(6).doubleValue();

                Path2D mean = new Path2D.Double(Path2D.WIND_NON_ZERO);

                // july 2008
                // modified to show de-selected fractions as gray
                // this means a new special list of fractionIDs is created fromall non-rejected fractions
                // and each instance is tested for being included
                // should eventually refactor
                Vector<String> allFIDs = new Vector<String>();
                for (String f : ((UPbReduxAliquot) SAM.getAliquot()).getAliquotFractionIDs()) {
                    // test added for Sample-based wm
                    if (SAM.fractionDateIsPositive(//
                            ((UPbReduxAliquot) SAM.getAliquot()).getAliquotFractionByName(f))) {
                        allFIDs.add(f);
                    }
                }

                final int iFinal = i;
                if (fractionSortOrder.equalsIgnoreCase("weight")) {
                    Collections.sort(allFIDs, new Comparator<String>() {

                        public int compare(String fID1, String fID2) {
                            double invertOneSigmaF1 = //
                                    1.0 //
                                            / ((UPbReduxAliquot) selectedSampleDateModels[iFinal][0])//
                                                    .getAliquotFractionByName(fID1)//
                                                    .getRadiogenicIsotopeDateByName(SAM.getDateName())//
                                                    .getOneSigmaAbs().movePointLeft(6).doubleValue();
                            double invertOneSigmaF2 = //
                                    1.0 //
                                            / ((UPbReduxAliquot) selectedSampleDateModels[iFinal][0])//
                                                    .getAliquotFractionByName(fID2)//
                                                    .getRadiogenicIsotopeDateByName(SAM.getDateName())//
                                                    .getOneSigmaAbs().movePointLeft(6).doubleValue();

                            return Double.compare(invertOneSigmaF2, invertOneSigmaF1);
                        }
                    });
                } else if (fractionSortOrder.equalsIgnoreCase("date")) {
                    Collections.sort(allFIDs, new Comparator<String>() {

                        public int compare(String fID1, String fID2) {
                            double dateF1 = //
                                    ((UPbReduxAliquot) selectedSampleDateModels[iFinal][0])//
                                            .getAliquotFractionByName(fID1)//
                                            .getRadiogenicIsotopeDateByName(SAM.getDateName())//
                                            .getValue().doubleValue();
                            double dateF2 = //
                                    ((UPbReduxAliquot) selectedSampleDateModels[iFinal][0])//
                                            .getAliquotFractionByName(fID2)//
                                            .getRadiogenicIsotopeDateByName(SAM.getDateName())//
                                            .getValue().doubleValue();

                            return Double.compare(dateF1, dateF2);
                        }
                    });
                } else if ( /* ! isInRandomMode() &&*/fractionSortOrder.equalsIgnoreCase("random")) {
                    Collections.shuffle(allFIDs, new Random());
                } else if (fractionSortOrder.equalsIgnoreCase("name")) {
                    // default to alphabetic by name
                    //Collections.sort(allFIDs);
                    // april 2010 give same lexigraphic ordering that UPbFractions get
                    Collections.sort(allFIDs, new IntuitiveStringComparator<String>());
                } else {
                    // do nothing
                }

                double actualWidthX = (allFIDs.size()) * (barWidth + barGap);//; + barGap;

                // plot 2-sigma of mean
                mean.moveTo((float) mapX(startSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean + 2.0 * wMeanOneSigma, getMaxY_Display(), rangeY, graphHeight));
                mean.lineTo((float) mapX(startSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean + 2.0 * wMeanOneSigma, getMaxY_Display(), rangeY, graphHeight));
                mean.lineTo((float) mapX(startSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean - 2.0 * wMeanOneSigma, getMaxY_Display(), rangeY, graphHeight));
                mean.lineTo((float) mapX(startSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean - 2.0 * wMeanOneSigma, getMaxY_Display(), rangeY, graphHeight));
                mean.closePath();

                g2d.setColor(ReduxConstants.mySampleYellowColor);
                g2d.fill(mean);
                g2d.setPaint(Color.BLACK);

                // plot 1-sigma of mean
                mean.reset();
                mean.moveTo((float) mapX(startSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean + wMeanOneSigma, getMaxY_Display(), rangeY, graphHeight));
                mean.lineTo((float) mapX(startSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean + wMeanOneSigma, getMaxY_Display(), rangeY, graphHeight));
                mean.lineTo((float) mapX(startSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean - wMeanOneSigma, getMaxY_Display(), rangeY, graphHeight));
                mean.lineTo((float) mapX(startSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean - wMeanOneSigma, getMaxY_Display(), rangeY, graphHeight));
                mean.closePath();

                g2d.setColor(ReduxConstants.ColorOfRedux);
                g2d.fill(mean);
                g2d.setPaint(Color.BLACK);

                // plot mean
                mean.reset();
                mean.moveTo((float) mapX(startSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean, getMaxY_Display(), rangeY, graphHeight));
                mean.lineTo((float) mapX(startSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(wMean, getMaxY_Display(), rangeY, graphHeight));
                g2d.setStroke(new BasicStroke(1.0f));
                g2d.draw(mean);
                g2d.setStroke(new BasicStroke(2.0f));

                saveStartSamX = startSamX;

                // plot fraction bars
                double minPoint = 5000.0;
                double maxWeight = 0.0;
                double totalWeight = 0.0;

                int barNum = 0;

                for (String fID : allFIDs) {
                    // the dateModel has an associated aliquot, but in sample mode, it is a
                    // standin aliquot for the sample.  to get the aliquot number for
                    // use in coloring fractions, we need to query the fraction itself
                    String aliquotName = sample.getAliquotNameByFractionID(fID);

                    Color includedFillColor = new Color(0, 0, 0);
                    if (sample.getSampleDateInterpretationGUISettings().getAliquotOptions().get(aliquotName)
                            .containsKey("includedFillColor")) {
                        String[] temp = //
                                sample.getSampleDateInterpretationGUISettings().getAliquotOptions()
                                        .get(aliquotName).get("includedFillColor").split(",");
                        includedFillColor = buildRGBColor(temp);
                    }

                    Fraction f = ((UPbReduxAliquot) selectedSampleDateModels[i][0])
                            .getAliquotFractionByName(fID);

                    double date = f.//((UPbReduxAliquot) selectedSampleDateModels[i][0]).getAliquotFractionByName(fID).//
                            getRadiogenicIsotopeDateByName(SAM.getDateName()).getValue().movePointLeft(6)
                            .doubleValue();
                    double twoSigma = f.//((UPbReduxAliquot) selectedSampleDateModels[i][0]).getAliquotFractionByName(fID).//
                            getRadiogenicIsotopeDateByName(SAM.getDateName()).getTwoSigmaAbs().movePointLeft(6)
                            .doubleValue();

                    if ((date - twoSigma) < minPoint) {
                        minPoint = (date - twoSigma);
                    }

                    double invertedOneSigma = //
                            1.0 //
                                    / f.//((UPbReduxAliquot) selectedSampleDateModels[i][0]).getAliquotFractionByName(fID).//
                                            getRadiogenicIsotopeDateByName(SAM.getDateName()).getOneSigmaAbs()
                                            .movePointLeft(6).doubleValue();

                    if (invertedOneSigma > maxWeight) {
                        maxWeight = invertedOneSigma;
                    }

                    Path2D bar = new Path2D.Double(Path2D.WIND_NON_ZERO);
                    bar.moveTo(
                            (float) mapX(saveStartSamX + ((barGap / 2.0) + barNum * (barWidth + barGap)),
                                    getMinX_Display(), rangeX, graphWidth),
                            (float) mapY(date + twoSigma, getMaxY_Display(), rangeY, graphHeight));
                    bar.lineTo(
                            (float) mapX(
                                    saveStartSamX + ((barGap / 2.0) + barNum * (barWidth + barGap)) + barWidth,
                                    getMinX_Display(), rangeX, graphWidth),
                            (float) mapY(date + twoSigma, getMaxY_Display(), rangeY, graphHeight));
                    bar.lineTo(
                            (float) mapX(
                                    saveStartSamX + ((barGap / 2.0) + barNum * (barWidth + barGap)) + barWidth,
                                    getMinX_Display(), rangeX, graphWidth),
                            (float) mapY(date - twoSigma, getMaxY_Display(), rangeY, graphHeight));
                    bar.lineTo(
                            (float) mapX(saveStartSamX + ((barGap / 2.0) + barNum * (barWidth + barGap)),
                                    getMinX_Display(), rangeX, graphWidth),
                            (float) mapY(date - twoSigma, getMaxY_Display(), rangeY, graphHeight));
                    bar.closePath();

                    Composite originalComposite = g2d.getComposite();

                    if (SAM.getIncludedFractionIDsVector().contains(fID)) {
                        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
                        totalWeight += Math.pow(invertedOneSigma, 2.0);

                        // april 2014 experiment
                        if (f.getRgbColor() != 0) {
                            includedFillColor = new Color(f.getRgbColor());
                        }

                    } else {
                        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
                    }

                    g2d.setPaint(includedFillColor);

                    g2d.draw(bar);
                    //restore composite
                    g2d.setComposite(originalComposite);

                    g2d.setColor(Color.black);

                    // label fraction at top
                    g2d.rotate(-Math.PI / 4.0,
                            (float) mapX(saveStartSamX + ((barGap / 2.0) + barNum * (barWidth + barGap)),
                                    getMinX_Display(), rangeX, graphWidth),
                            (float) mapY(date + twoSigma, getMaxY_Display(), rangeY, graphHeight));

                    g2d.drawString(
                            ((UPbReduxAliquot) selectedSampleDateModels[i][0]).getAliquotFractionByName(fID)
                                    .getFractionID(),
                            (float) mapX(saveStartSamX + ((barGap / 2.0) + barNum * (barWidth + barGap)),
                                    getMinX_Display(), rangeX, graphWidth) + 15,
                            (float) mapY(date + twoSigma, getMaxY_Display(), rangeY, graphHeight));

                    g2d.rotate(Math.PI / 4.0,
                            (float) mapX(saveStartSamX + ((barGap / 2.0) + barNum * (barWidth + barGap)),
                                    getMinX_Display(), rangeX, graphWidth),
                            (float) mapY(date + twoSigma, getMaxY_Display(), rangeY, graphHeight));

                    barNum++;
                    // startSamX += 2 * barWidth;
                    startSamX += barWidth + barGap;
                }

                // display three info boxes below weighted means
                // each tic is the height of one calculated y-axis tic
                // determine the y axis tic
                double minYtic = Math.ceil(getMinY_Display() * 100) / 100;
                double maxYtic = Math.floor(getMaxY_Display() * 100) / 100;
                double deltay = Math.rint((maxYtic - minYtic) * 10 + 0.5);
                double yTic = deltay / 100;

                double yTopSummary = minPoint - yTic / 2.0;// wMeanOneSigma;
                //double specialYTic = yTic;
                double yTopWeights = yTopSummary - yTic * 1.1;
                double yTopMSWD_PDF = yTopWeights - yTic * 1.1;

                // summary box
                Path2D box = new Path2D.Double(Path2D.WIND_NON_ZERO);
                box.moveTo((float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopSummary, getMaxY_Display(), rangeY, graphHeight));
                box.lineTo((float) mapX(saveStartSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopSummary, getMaxY_Display(), rangeY, graphHeight));
                box.lineTo((float) mapX(saveStartSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopSummary - yTic, getMaxY_Display(), rangeY, graphHeight));
                box.lineTo((float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopSummary - yTic, getMaxY_Display(), rangeY, graphHeight));
                box.closePath();

                g2d.setStroke(new BasicStroke(1.5f));
                g2d.draw(box);

                // Info Box
                g2d.drawString(//
                        SAM.getAliquot().getAliquotName(),
                        (float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth) + 4f,
                        (float) mapY(yTopSummary, getMaxY_Display(), rangeY, graphHeight) + 13f);
                g2d.drawString(//
                        SAM.getName(), (float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth) + 4f,
                        (float) mapY(yTopSummary, getMaxY_Display(), rangeY, graphHeight) + 25f);
                g2d.drawString(//
                        SAM.FormatValueAndTwoSigmaABSThreeWaysForPublication(6, 2),
                        (float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth) + 4f,
                        (float) mapY(yTopSummary, getMaxY_Display(), rangeY, graphHeight) + 36f);
                g2d.drawString(//
                        SAM.ShowCustomMSWDwithN(),
                        (float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth) + 4f,
                        (float) mapY(yTopSummary, getMaxY_Display(), rangeY, graphHeight) + 48f);

                // weights box
                box.reset();
                box.moveTo((float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopWeights, getMaxY_Display(), rangeY, graphHeight));
                box.lineTo((float) mapX(saveStartSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopWeights, getMaxY_Display(), rangeY, graphHeight));
                box.lineTo((float) mapX(saveStartSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopWeights - yTic, getMaxY_Display(), rangeY, graphHeight));
                box.lineTo((float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopWeights - yTic, getMaxY_Display(), rangeY, graphHeight));
                box.closePath();

                g2d.setStroke(new BasicStroke(1.5f));
                g2d.draw(box);

                // plot fraction weights
                double artificialXRange = allFIDs.size();
                double count = 0;
                //double weightWidth = Math.min(3.0 * barWidth, (yTic / rangeY * graphHeight)) - 15;//yTic;//barWidth * 2.0;
                double weightWidth = (barWidth + barGap) * 0.9;

                for (String fID : allFIDs) {
                    // the dateModel has an associated aliquot, but in sample mode, it is a
                    // standin aliquot for the sample.  to get the aliquot number for
                    // use in coloring fractions, we need to query the fraction itself
                    String aliquotName = sample.getAliquotNameByFractionID(fID);

                    Fraction f = ((UPbReduxAliquot) selectedSampleDateModels[i][0])
                            .getAliquotFractionByName(fID);

                    Color includedFillColor = new Color(0, 0, 0);
                    if (sample.getSampleDateInterpretationGUISettings().getAliquotOptions().get(aliquotName)
                            .containsKey("includedFillColor")) {
                        String[] temp = //
                                sample.getSampleDateInterpretationGUISettings().getAliquotOptions()
                                        .get(aliquotName).get("includedFillColor").split(",");
                        includedFillColor = buildRGBColor(temp);
                    }

                    double invertOneSigma = //
                            1.0 //
                                    / ((UPbReduxAliquot) selectedSampleDateModels[i][0])
                                            .getAliquotFractionByName(fID)//
                                            .getRadiogenicIsotopeDateByName(SAM.getDateName()).getOneSigmaAbs()
                                            .movePointLeft(6).doubleValue();

                    Path2D weight = new Path2D.Double(Path2D.WIND_NON_ZERO);
                    weight.moveTo(
                            (float) mapX(saveStartSamX + (count + 0.5) / artificialXRange * actualWidthX,
                                    getMinX_Display(), rangeX, graphWidth) //
                                    - (float) (invertOneSigma / maxWeight / 2.0 * weightWidth),
                            (float) mapY(yTopWeights - (yTic / 2.0), getMaxY_Display(), rangeY, graphHeight) //
                                    + (float) (invertOneSigma / maxWeight / 2.0 * weightWidth) - 5f);

                    weight.lineTo(
                            (float) mapX(saveStartSamX + (count + 0.5) / artificialXRange * actualWidthX,
                                    getMinX_Display(), rangeX, graphWidth) //
                                    + (float) (invertOneSigma / maxWeight / 2.0 * weightWidth),
                            (float) mapY(yTopWeights - (yTic / 2.0), getMaxY_Display(), rangeY, graphHeight) //
                                    + (float) (invertOneSigma / maxWeight / 2.0 * weightWidth) - 5f);

                    weight.lineTo(
                            (float) mapX(saveStartSamX + (count + 0.5) / artificialXRange * actualWidthX,
                                    getMinX_Display(), rangeX, graphWidth) //
                                    + (float) (invertOneSigma / maxWeight / 2.0 * weightWidth),
                            (float) mapY(yTopWeights - (yTic / 2.0), getMaxY_Display(), rangeY, graphHeight) //
                                    - (float) (invertOneSigma / maxWeight / 2.0 * weightWidth) - 5f);

                    weight.lineTo(
                            (float) mapX(saveStartSamX + (count + 0.5) / artificialXRange * actualWidthX,
                                    getMinX_Display(), rangeX, graphWidth) //
                                    - (float) (invertOneSigma / maxWeight / 2.0 * weightWidth),
                            (float) mapY(yTopWeights - (yTic / 2.0), getMaxY_Display(), rangeY, graphHeight) //
                                    - (float) (invertOneSigma / maxWeight / 2.0 * weightWidth) - 5f);

                    weight.closePath();

                    g2d.setStroke(new BasicStroke(2.5f));

                    // test for included or not == black or gray
                    String weightPerCent = "   0";//0.0%";

                    //                        g2d.setPaint(includedFillColor);
                    Composite originalComposite = g2d.getComposite();

                    if (SAM.getIncludedFractionIDsVector().contains(fID)) {
                        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
                        weightPerCent = formatter1DecPlace
                                .format(Math.pow(invertOneSigma, 2.0) / totalWeight * 100.0);// + "%";

                        // april 2014 experiment
                        if (f.getRgbColor() != 0) {
                            includedFillColor = new Color(f.getRgbColor());
                        }
                    } else {
                        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
                    }

                    g2d.setPaint(includedFillColor);

                    g2d.fill(weight);
                    //restore composite
                    g2d.setComposite(originalComposite);

                    // write percent of total weight
                    g2d.drawString(weightPerCent,
                            (float) mapX(saveStartSamX + (count + 0.5) / artificialXRange * actualWidthX,
                                    getMinX_Display(), rangeX, graphWidth) //
                                    - (float) (invertOneSigma / maxWeight / 2.0 * weightWidth),
                            (float) mapY(yTopWeights - yTic, getMaxY_Display(), rangeY, graphHeight) - 5f);
                    g2d.setColor(Color.black);

                    count += 1.0;

                }

                // double box height for graph
                yTic *= 2.0;

                // plot MSWD_PDF
                // store  function x,y values
                Vector<Double> xVals = new Vector<Double>();
                Vector<Double> yVals = new Vector<Double>();

                double f = SAM.getIncludedFractionIDsVector().size() - 1;
                if (f > 1.0) {
                    g2d.setStroke(new BasicStroke(1.0f));

                    double yRange = MSWDCoordinates.valuesByPointCount[(int) f][5] * 1.03; // alitle air at the top of curve
                    double xStart = MSWDCoordinates.valuesByPointCount[(int) f][1];
                    double xRange = MSWDCoordinates.valuesByPointCount[(int) f][4] - xStart;
                    double xStep = 0.005;

                    Path2D MSWD_PDF = new Path2D.Double(Path2D.WIND_NON_ZERO);
                    Path2D MSWD_right = new Path2D.Double(Path2D.WIND_NON_ZERO);

                    // start at lower left corner of box  (may or may not be 0,0 )
                    MSWD_PDF.moveTo(//
                            (float) mapX((double) saveStartSamX, getMinX_Display(), rangeX, graphWidth),
                            (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight));

                    // setup MSWD to paint last
                    Path2D MSWD = null;

                    // calculate function values
                    for (double x = xStart; x < xRange; x += xStep) {
                        xVals.add((((x - xStart) / xRange) * actualWidthX) + (double) saveStartSamX);

                        double y = //
                                Math.pow(2, -1.0 * f / 2.0)//
                                        * Math.exp(-1.0 * f * x / 2.0)//
                                        * Math.pow(f, f / 2.0)//
                                        * Math.pow(x, (-1.0 + f / 2.0))//
                                        / Math.exp(Gamma.logGamma(f / 2.0));

                        yVals.add(((y / yRange) * yTic) + yTopMSWD_PDF - yTic);

                        MSWD_PDF.lineTo(//
                                (float) mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                (float) mapY(yVals.lastElement(), getMaxY_Display(), rangeY, graphHeight));

                        // test for location of left RED zone
                        if ((MSWDCoordinates.valuesByPointCount[(int) f][2] >= x)
                                && (MSWDCoordinates.valuesByPointCount[(int) f][2] < (x + xStep))) {

                            double leftX = MSWDCoordinates.valuesByPointCount[(int) f][2];
                            xVals.add((((leftX - xStart) / xRange) * actualWidthX) + (double) saveStartSamX);

                            double leftY = //
                                    Math.pow(2, -1.0 * f / 2.0)//
                                            * Math.exp(-1.0 * f * leftX / 2.0)//
                                            * Math.pow(f, f / 2.0)//
                                            * Math.pow(leftX, (-1.0 + f / 2.0))//
                                            / Math.exp(Gamma.logGamma(f / 2.0));
                            yVals.add(((leftY / yRange) * yTic) + yTopMSWD_PDF - yTic);

                            MSWD_PDF.lineTo(//
                                    (float) mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    (float) mapY(yVals.lastElement(), getMaxY_Display(), rangeY, graphHeight));

                            Path2D ciLower = new Path2D.Double(Path2D.WIND_NON_ZERO);
                            ciLower.append(MSWD_PDF.getPathIterator(new AffineTransform()), true);

                            ciLower.lineTo(//
                                    (float) mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight));
                            ciLower.closePath();
                            g2d.setColor(Color.RED);
                            g2d.fill(ciLower);

                            // draw right hand border line to compensate for a bug in the filler
                            Line2D right = new Line2D.Double(//
                                    mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    mapY(yVals.lastElement(), getMaxY_Display(), rangeY, graphHeight),
                                    mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight));
                            g2d.setStroke(new BasicStroke(0.5f));
                            g2d.draw(right);
                            g2d.setStroke(new BasicStroke(1.0f));

                            g2d.setColor(Color.BLACK);

                            System.out.println("Left Red = (" + leftX + ", " + leftY + ")");
                        }

                        // test for location of right RED zone
                        if ((MSWDCoordinates.valuesByPointCount[(int) f][3] >= x)
                                && (MSWDCoordinates.valuesByPointCount[(int) f][3] < (x + xStep))) {

                            double rightX = MSWDCoordinates.valuesByPointCount[(int) f][3];
                            xVals.add((((rightX - xStart) / xRange) * actualWidthX) + (double) saveStartSamX);

                            double rightY = //
                                    Math.pow(2, -1.0 * f / 2.0)//
                                            * Math.exp(-1.0 * f * rightX / 2.0)//
                                            * Math.pow(f, f / 2.0)//
                                            * Math.pow(rightX, (-1.0 + f / 2.0))//
                                            / Math.exp(Gamma.logGamma(f / 2.0));
                            yVals.add(((rightY / yRange) * yTic) + yTopMSWD_PDF - yTic);

                            MSWD_PDF.lineTo(//
                                    (float) mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    (float) mapY(yVals.lastElement(), getMaxY_Display(), rangeY, graphHeight));

                            // here the strategy is to draw the curve and then reset it to record the remainder
                            g2d.setStroke(new BasicStroke(1.0f));
                            g2d.draw(MSWD_PDF);
                            MSWD_PDF = new Path2D.Double(Path2D.WIND_NON_ZERO);
                            MSWD_PDF.moveTo(//
                                    (float) mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    (float) mapY(yVals.lastElement(), getMaxY_Display(), rangeY, graphHeight));

                            MSWD_right.moveTo(//
                                    (float) mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight));
                            MSWD_right.lineTo(//
                                    (float) mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    (float) mapY(yVals.lastElement(), getMaxY_Display(), rangeY, graphHeight));

                            System.out.println("Right Red = (" + rightX + ", " + rightY + ")");

                        }

                        // test for location of MSWD AND paint last
                        if ((SAM.getMeanSquaredWeightedDeviation().doubleValue() >= x)
                                && (SAM.getMeanSquaredWeightedDeviation().doubleValue() < (x + xStep))) {
                            MSWD = new Path2D.Double(Path2D.WIND_NON_ZERO);
                            MSWD.moveTo(//
                                    (float) mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight));
                            MSWD.lineTo(//
                                    (float) mapX(xVals.lastElement(), getMinX_Display(), rangeX, graphWidth),
                                    (float) mapY(yVals.lastElement(), getMaxY_Display(), rangeY, graphHeight));

                        }
                    }
                    g2d.setStroke(new BasicStroke(1.0f));
                    // merge with border of right RED and fill
                    MSWD_right.append(MSWD_PDF.getPathIterator(new AffineTransform()), true);
                    g2d.setColor(Color.RED);
                    g2d.fill(MSWD_right);
                    g2d.setColor(Color.BLACK);
                    // draw the remaining curves
                    g2d.draw(MSWD_PDF);
                    // MSWD may be off the graph and hence not exist
                    try {
                        g2d.draw(MSWD);
                    } catch (Exception e) {
                    }

                    // label 95% conf interval and MSWD
                    g2d.drawString(//
                            "95% CI: ("
                                    + formatter2DecPlaces.format(MSWDCoordinates.valuesByPointCount[(int) f][2])
                                    + ", "
                                    + formatter2DecPlaces.format(MSWDCoordinates.valuesByPointCount[(int) f][3])
                                    + ")",
                            (float) mapX(saveStartSamX + (actualWidthX / 2.0), getMinX_Display(), rangeX,
                                    graphWidth) - 30f,
                            (float) mapY(yTopMSWD_PDF, getMaxY_Display(), rangeY, graphHeight) + 15f);

                    // determine if MSWD is out of range
                    String mswdAlert = "";
                    if (SAM.getMeanSquaredWeightedDeviation()
                            .doubleValue() > MSWDCoordinates.valuesByPointCount[(int) f][4]) {
                        mswdAlert = "\n !Out of Range!";
                    }
                    g2d.drawString(//
                            "MSWD = "
                                    + formatter2DecPlaces
                                            .format(SAM.getMeanSquaredWeightedDeviation().doubleValue())
                                    + ", n = " + (int) (f + 1) + mswdAlert,
                            (float) mapX(saveStartSamX + (actualWidthX / 2.0), getMinX_Display(), rangeX,
                                    graphWidth) - 15f,
                            (float) mapY(yTopMSWD_PDF, getMaxY_Display(), rangeY, graphHeight) + 30f);

                } else {
                    g2d.drawString("need more data...",
                            (float) mapX((double) saveStartSamX, getMinX_Display(), rangeX, graphWidth) + 4f,
                            (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight) - 10f);
                }

                // MSWD_PDF box
                box.reset();
                box.moveTo((float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopMSWD_PDF, getMaxY_Display(), rangeY, graphHeight));
                box.lineTo((float) mapX(saveStartSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopMSWD_PDF, getMaxY_Display(), rangeY, graphHeight));
                box.lineTo((float) mapX(saveStartSamX + actualWidthX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight));
                box.lineTo((float) mapX(saveStartSamX, getMinX_Display(), rangeX, graphWidth),
                        (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight));
                box.closePath();

                g2d.setStroke(new BasicStroke(1.5f));
                g2d.draw(box);

                // MSWD_PDF x-axis tics
                if (f > 1.0) {
                    g2d.setStroke(new BasicStroke(1.0f));
                    double xStart = (MSWDCoordinates.valuesByPointCount[(int) f][1] <= 0.5) ? 0.5 : 1.0;
                    double xRange = MSWDCoordinates.valuesByPointCount[(int) f][4]
                            - MSWDCoordinates.valuesByPointCount[(int) f][1];
                    double xStep = 0.5;

                    for (double x = xStart; x < xRange; x += xStep) {
                        double xPlot = (((x - MSWDCoordinates.valuesByPointCount[(int) f][1]) / xRange)
                                * actualWidthX) + (double) saveStartSamX;
                        Line2D line = new Line2D.Double(mapX(xPlot, getMinX_Display(), rangeX, graphWidth),
                                mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight),
                                mapX(xPlot, getMinX_Display(), rangeX, graphWidth),
                                mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight) + 7);
                        g2d.draw(line);

                        g2d.rotate(-Math.PI / 2.0, (float) mapX(xPlot, getMinX_Display(), rangeX, graphWidth),
                                (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight));
                        g2d.drawString(formatter1DecPlace.format(x),
                                (float) mapX(xPlot, getMinX_Display(), rangeX, graphWidth) - 30f,
                                (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight) + 5f);
                        g2d.rotate(Math.PI / 2.0, (float) mapX(xPlot, getMinX_Display(), rangeX, graphWidth),
                                (float) mapY(yTopMSWD_PDF - yTic, getMaxY_Display(), rangeY, graphHeight));
                    }
                }

                // set counters
                barNum += samSpace;
                startSamX += 2 * samSpace * barWidth;
            }
        }
    }
    //        // prevents re-randomization
    //        setInRandomMode( true );

    drawAxesAndTicks(g2d, rangeX, rangeY);

    // draw zoom box if in use
    if ((Math.abs(zoomMaxX - zoomMinX) * Math.abs(zoomMinY - zoomMaxY)) > 0.0) {
        g2d.setStroke(new BasicStroke(2.0f));
        g2d.setColor(Color.red);
        g2d.drawRect(//
                Math.min(zoomMinX, zoomMaxX), Math.min(zoomMaxY, zoomMinY), Math.abs(zoomMaxX - zoomMinX),
                Math.abs(zoomMinY - zoomMaxY));
    }
}