Package jsky.science

Examples of jsky.science.Time


     * zoom the time line out with center point centerPt being at the center
     *
     * @param centerPt the point to center the zoom around
     */
    public void zoomOut(Point centerPt) {
        Time center = getTimeForPoint(centerPt.x);
        double currentWindowWidth = _displayEnd.getValue(Time.SECOND)
                - _displayStart.getValue(Time.SECOND);
        currentWindowWidth = currentWindowWidth * 2;
        double maxWidth = getEndTime().getValue(Time.SECOND)
                - getStartTime().getValue(Time.SECOND);
        if (currentWindowWidth > maxWidth) {
            currentWindowWidth = maxWidth;
        }


        double startX = Math.floor((center.getValue(Time.SECOND) - currentWindowWidth / 2.0));
        double endX = Math.floor((center.getValue(Time.SECOND) + currentWindowWidth / 2.0));
        if (startX < getStartTime().getValue(Time.SECOND)) {
            double adjust = getStartTime().getValue(Time.SECOND) - startX;
            startX += adjust;
            endX += adjust;
        }
        if (endX > getEndTime().getValue(Time.SECOND)) {
            double adjust = endX - getEndTime().getValue(Time.SECOND);
            startX -= adjust;
            endX -= adjust;
        }
        Time startTime = new Time(startX, Time.SECOND);
        Time endTime = new Time(endX, Time.SECOND);
        setDisplayArea(startTime, endTime);

    }
View Full Code Here


        TimeLineModel model = new DefaultTimeLineModel(0, 40, 10);
        timeLine.setModel(model);

        try {
            timeLine.addTimeLineNode(new BlockTimeLineNode(new Time(0), new Time(5.0 * 60.0), "Block 1"));

            String label1 = "Label 1";
            DefaultTimeLineNode node1 = new DefaultTimeLineNode(new Time(8.0 * 60.0), new Time(12.0 * 60.0), label1) {

                public String getDescription(Point pt) {
                    // Note: like tooltip for node, can return plain or HTML text here,
                    // see gov.nasa.gsfc.sea.exposureplanner.gui.ExposureTimeLineNodeModel for example
                    String details = "<html><font size='-2'>";
                    details += "<table width=" + '"' + "100%" + '"' + " border=0 cellpadding=0 cellspacing=0 >";
                    details += "<caption align='TOP'><font siz='-1'><div align=center><b>Node Info</b></div></font></caption>";
                    details += "Test info";
                    details += "</table>";
                    details += "</font></html>";
                    return details;
                }
            };
            timeLine.addTimeLineNode(node1);
            node1.addVetoableChangeListener(new VetoableChangeListener() {

                public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
                    System.out.println("XXX node 1 changed: " + evt);
                }
            });

            String label2 = "Label 2";
            DefaultTimeLineNode node2 = new DefaultTimeLineNode(new Time(24.0 * 60.0), new Time(30.0 * 60.0), label2) {

                public String getDescription(Point pt) {
                    return "Node Description";
                }
            };
View Full Code Here

    /**
     * set the time that this node starts
     */
    public void setStartTime(Time time) throws DetailedPropertyVetoException {
        if (time.getValue(Time.SECOND) != fModel.getStartTime().getValue(Time.SECOND)) {
            Time oldTime = fModel.getStartTime();
            try {
                fModel.setValidStartTime(time);

                Time displayEdge = fTimeLine.getDisplayStart();
                if ((getStartTime().getValue() < displayEdge.getValue() &&
                        oldTime.getValue() >= displayEdge.getValue())) {
                    fChangeSupport.fireVetoableChange(TimeLineNode.HIT_LEFT_EDGE, oldTime, time);
                    fForceRecalculation = true;
                }


View Full Code Here

    /**
     * move node by specified amount
     */
    public synchronized void moveTimeLineNodeBy(Time time) throws DetailedPropertyVetoException {
        if (time.getValue() != 0.0) {
            Time oldStartTime = fModel.getStartTime();
            Time oldEndTime = fModel.getEndTime();
            try {
                fModel.moveTimeLineNodeByValid(time);
                if (fTimeLine != null) {
                    if (time.getValue() < 0d) {
                        Time displayEdge = fTimeLine.getDisplayStart();
                        if ((getStartTime().getValue() < displayEdge.getValue() &&
                                oldStartTime.getValue() >= displayEdge.getValue())) {
                            fChangeSupport.fireVetoableChange(TimeLineNode.HIT_LEFT_EDGE,
                                    oldStartTime, getStartTime());
                            fForceRecalculation = true;

                        }


                    } else {
                        Time displayEdge = fTimeLine.getDisplayEnd();
                        if ((getEndTime().getValue() > displayEdge.getValue() &&
                                oldEndTime.getValue() <= displayEdge.getValue())) {
                            fChangeSupport.fireVetoableChange(TimeLineNode.HIT_RIGHT_EDGE, oldEndTime, time);
                            fForceRecalculation = true;
                        }

                    }
View Full Code Here

    /**
     * set the time on the time line that this node ends
     */
    public void setEndTime(Time time) throws DetailedPropertyVetoException {
        if (time.getValue(Time.SECOND) != fModel.getEndTime().getValue(Time.SECOND)) {
            Time oldTime = fModel.getEndTime();
            try {
                if (time.getValue(Time.SECOND) > getStartTime().getValue(Time.SECOND)) {
                    fModel.setValidEndTime(time);
                    Time displayEdge = fTimeLine.getDisplayEnd();
                    if ((fModel.getEndTime().getValue() > displayEdge.getValue() &&
                            oldTime.getValue() <= displayEdge.getValue())) {
                        fChangeSupport.fireVetoableChange(TimeLineNode.HIT_RIGHT_EDGE, oldTime, time);
                        fForceRecalculation = true;
                    }
                } else {
                    throw new DetailedPropertyVetoException(this, TimeLineNode.NODE_MIN_SIZE_EXCEEDED,
View Full Code Here

    /**
     * set the duration of the time line node
     */
    public void setDuration(Time durationLength) throws DetailedPropertyVetoException {
        if (fTimeLine != null) {
            setEndTime(new Time(fModel.getStartTime().getValue(Time.SECOND) +
                    durationLength.getValue(Time.SECOND), Time.SECOND));
        }
    }
View Full Code Here

    public void paintTimeLineNode(Graphics2D graphics) {
        Font origFont = graphics.getFont();
        graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        Time startTime = fModel.getStartTime();
        Time endTime = fModel.getEndTime();

        boolean addHandles = true;
        if (!((startTime.getValue(Time.SECOND) > fTimeLine.getDisplayEnd().getValue(Time.SECOND)) ||
                (endTime.getValue(Time.SECOND) < fTimeLine.getDisplayStart().getValue(Time.SECOND)))) {
            if ((fDragMode == TimeLineNode.UNSELECTED) || fForceRecalculation) {
                calculateNodeDimensions();
                fForceRecalculation = false;
            } else {
                float thumbMin = fTimeLine.getPointForTime(fTimeLine.getDisplayStart());
                float thumbMax = fTimeLine.getPointForTime(fTimeLine.getDisplayEnd());

                if (fThumbBegin < thumbMin) {
                    fThumbBegin = thumbMin;
                }

                if (fThumbEnd > thumbMax) {
                    fThumbEnd = thumbMax;
                }
            }
            float thumbLengthMin = 2f * fHandleWidth;
            float thumbWidth = (fThumbEnd - fThumbBegin);
            float thumbHeight = fThumbHeight;
            if (thumbWidth < thumbLengthMin) {
                thumbHeight = fHandleHeight;
                addHandles = false;
            }

            // draw the thumb
            fThumb.height = thumbHeight;
            fThumb.width = thumbWidth;
            fThumb.x = fThumbBegin;
            fThumb.y = (fTimeLine.getHeight() / 2f - thumbHeight / 2f);
            graphics.setStroke(fDefaultStroke);

            if (fMode == TimeLineNode.NODE_SELECTED) {
                graphics.setColor(fSelectedColor);
            } else {
                graphics.setColor(fUnselectedColor);
            }
            graphics.draw(fThumb);
            graphics.fill(fThumb);


            // this is the bottom shadow line of the thumb
            fThumbShadowLine.x1 = fThumb.x;
            fThumbShadowLine.y1 = fThumb.y + thumbHeight;
            fThumbShadowLine.x2 = fThumb.x + thumbWidth;
            fThumbShadowLine.y2 = fThumb.y + thumbHeight;

            graphics.setStroke(fShadowStroke);
            graphics.setColor(Color.black);
            graphics.draw(fThumbShadowLine);

            // this is the top shadow line of the thumb
            fThumbTopShadowLine.x1 = fThumb.x;
            fThumbTopShadowLine.y1 = fThumb.y;
            fThumbTopShadowLine.x2 = fThumb.x + thumbWidth;
            fThumbTopShadowLine.y2 = fThumb.y;

            graphics.setStroke(fShadowStroke);
            graphics.setColor(Color.white);
            graphics.draw(fThumbTopShadowLine);


            double length = endTime.getValue(Time.MINUTE) - startTime.getValue(Time.MINUTE);

            if ((startTime.getValue(Time.SECOND) >= fTimeLine.getDisplayStart().getValue(Time.SECOND)) &&
                    (addHandles)) {
                // draw left handle
                fLeftHandle.height = fHandleHeight;
                fLeftHandle.width = fHandleWidth;
                fLeftHandle.x = fThumb.x;
                fLeftHandle.y = (float) fTimeLine.getHeight() / 2f - fHandleHeight / 2f;
                graphics.setStroke(fDefaultStroke);
                if ((fMode == TimeLineNode.LEFT_HANDLE_SELECTED) ||
                        (fMode == TimeLineNode.NODE_SELECTED)) {
                    graphics.setColor(fSelectedColor);
                } else {
                    graphics.setColor(fUnselectedColor);
                }
                graphics.draw(fLeftHandle);
                graphics.fill(fLeftHandle);
                graphics.setStroke(fShadowStroke);

                // these are shadow lines
                fLHandleBottomShadowLine.x1 = fLeftHandle.x;
                fLHandleBottomShadowLine.y1 = fLeftHandle.y + fHandleHeight;
                fLHandleBottomShadowLine.x2 = fLeftHandle.x + fHandleWidth;
                fLHandleBottomShadowLine.y2 = fLeftHandle.y + fHandleHeight;

                fLHandleRightShadowLine.x1 = fLeftHandle.x + fHandleWidth;
                fLHandleRightShadowLine.y1 = fLeftHandle.y;
                fLHandleRightShadowLine.x2 = fLeftHandle.x + fHandleWidth;
                fLHandleRightShadowLine.y2 = fLeftHandle.y + fHandleHeight;

                fLHandleLeftShadowLine.x1 = fLeftHandle.x;
                fLHandleLeftShadowLine.y1 = fLeftHandle.y;
                fLHandleLeftShadowLine.x2 = fLeftHandle.x;
                fLHandleLeftShadowLine.y2 = fLeftHandle.y + fHandleHeight;

                graphics.setColor(Color.black);
                graphics.draw(fLHandleBottomShadowLine);


                graphics.draw(fLHandleRightShadowLine);

                fLHandleTopShadowLine.x1 = fLeftHandle.x;
                fLHandleTopShadowLine.y1 = fLeftHandle.y;
                fLHandleTopShadowLine.x2 = fLeftHandle.x + fHandleWidth;
                fLHandleTopShadowLine.y2 = fLeftHandle.y;

                graphics.setColor(Color.white);
                graphics.draw(fLHandleTopShadowLine);
                graphics.draw(fLHandleLeftShadowLine);
            }

            if ((endTime.getValue(Time.SECOND) <= fTimeLine.getDisplayEnd().getValue(Time.SECOND)) && addHandles) {
                // draw Right handle
                fRightHandle.height = fHandleHeight;
                fRightHandle.width = fHandleWidth;
                fRightHandle.x = fThumb.x + thumbWidth - fHandleWidth;
                fRightHandle.y = (float) fTimeLine.getHeight() / 2f - fHandleHeight / 2f;
View Full Code Here

            } else if (fDragMode == TimeLineNode.NODE_SELECTED) {
                fThumbBegin = pt.x - fTempMouseOffset;
                fThumbEnd = fThumbBegin + fTempThumbWidth;
            }

            Time newStartTime = fTimeLine.getTimeForPoint(fThumbBegin);
            Time newEndTime = fTimeLine.getTimeForPoint(fThumbEnd);
            Time oldStartTime = getStartTime();

            try {
                if (fDragMode == TimeLineNode.NODE_SELECTED) {
                    if (newStartTime.getValue(Time.SECOND) != oldStartTime.getValue(Time.SECOND)) {
                        double moveByVal = newStartTime.getValue(Time.SECOND)
                                - oldStartTime.getValue(Time.SECOND);
                        moveTimeLineNodeBy(new Time(moveByVal, Time.SECOND));

                    }
                } else if (fDragMode == TimeLineNode.LEFT_HANDLE_SELECTED) {

                    setStartTime(newStartTime);
View Full Code Here

            } else if (evt.getKeyCode() != KeyEvent.VK_RIGHT) {
                interval = 0;
            }

            if (interval != 0) {
                Time anInterval = fTimeLine.getIntervalTime();
                Time intervalTime = new Time(anInterval.getValue(Time.SECOND) * interval, Time.SECOND);
                try {
                    if (getSelectionMode() == TimeLineNode.LEFT_HANDLE_SELECTED) {
                        setStartTime(new Time(getStartTime().getValue(Time.SECOND)
                                + intervalTime.getValue(Time.SECOND),
                                Time.SECOND));
                    } else if (getSelectionMode() == TimeLineNode.RIGHT_HANDLE_SELECTED) {
                        setEndTime(new Time(getEndTime().getValue(Time.SECOND)
                                + intervalTime.getValue(Time.SECOND),
                                Time.SECOND));
                    } else if (getSelectionMode() == TimeLineNode.NODE_SELECTED) {
                        moveTimeLineNodeBy(intervalTime);
                    }
                } catch (DetailedPropertyVetoException ex) {
View Full Code Here

     * returns the center point for the time line node
     */
    public Point getCenterPoint() {
        double value = fModel.getStartTime().getValue() +
                (fModel.getEndTime().getValue() - fModel.getStartTime().getValue()) / 2.0;
        Time centerTime = new Time(value);
        float x = fTimeLine.getPointForTime(centerTime);
        float y = fTimeLine.getHeight() / 2f;
        return new Point(Math.round(x), Math.round(y));
    }
View Full Code Here

TOP

Related Classes of jsky.science.Time

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