Package jsky.science

Examples of jsky.science.Time


    /**
     * move node to a specified location
     */
    public synchronized void setTimeLineNode(Time start, Time end) throws DetailedPropertyVetoException {

        Time oldStartTime = getStartTime();
        Time oldEndTime = getEndTime();
        try {

            fModel.setValidTimeLineNode(start, end);

            if (fTimeLine != null) {

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

                }


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


View Full Code Here


    /**
     * returns whether the specified point is in the node
     */
    public boolean containsPoint(Point pt) {
        boolean result = false;
        Time time = fTimeLine.getTimeForPoint(pt.x);
        if ((time.getValue() >= fModel.getStartTime().getValue()) &&
                (time.getValue() <= fModel.getEndTime().getValue())) {
            result = true;
        }
        return result;
    }
View Full Code Here

     * @param end the ending minute of the timeline
     * @param intervals the number of intervals on the timeline
     *
     **/
    public DefaultTimeLineModel(int start, int end, int intervals) {
        this(new Time((double) start, Time.MINUTE), new Time((double) end, Time.MINUTE), intervals);
    }
View Full Code Here

     * takes a date and convert it to a time where the new time is
     * equal to the date - start date
     *
     **/
    public Time getTimeForDate(Date date) {
        Time result = null;
        if (_startDate != null) {
            double startMilliSecs = (double) _startDate.getTime();
            double dateMilliSecs = (double) date.getTime();
            result = new Time((dateMilliSecs - startMilliSecs) / 1000.0, Time.SECOND);
        }
        return result;
    }
View Full Code Here

    /**
     * set the time that this node starts
     */
    public void setValidStartTime(Time time) throws DetailedPropertyVetoException {
        if (time.getValue(Time.SECOND) != getStartTime().getValue(Time.SECOND)) {
            Time oldTime = getStartTime();
            try {
                if (time.getValue(Time.SECOND) < getEndTime().getValue(Time.SECOND)) {
                    super.setStartTime(time);
                    fChangeSupport.fireVetoableChange(TimeLineNodeModel.START_TIME, oldTime, time);
                    fOldStartTime = oldTime;
View Full Code Here

    /**
     * move node by specified amount
     */
    public synchronized void moveTimeLineNodeByValid(Time time) throws DetailedPropertyVetoException {
        if (time.getValue(Time.SECOND) != 0) {
            Time oldStartTime = getStartTime();
            Time oldEndTime = getEndTime();
            try {

                super.moveTimeLineNodeBy(time);
                fOldStartTime = oldStartTime;
                fOldEndTime = oldEndTime;

                fChangeSupport.fireVetoableChange(TimeLineNodeModel.START_TIME, oldStartTime,
                        getStartTime());
                fChangeSupport.fireVetoableChange(TimeLineNodeModel.END_TIME, oldEndTime, getEndTime());


            } catch (DetailedPropertyVetoException ex) {
                super.moveTimeLineNodeBy(new Time(time.getValue() * -1.0));
                throw ex;
            } catch (PropertyVetoException ex) {
                ex.printStackTrace();
            }
        }
View Full Code Here

    /**
     * set the time on the time line that this node ends
     */
    public void setValidEndTime(Time time) throws DetailedPropertyVetoException {
        if (time.getValue(Time.SECOND) != getEndTime().getValue(Time.SECOND)) {
            Time oldTime = getEndTime();
            try {
                if (time.getValue(Time.SECOND) > getStartTime().getValue(Time.SECOND)) {
                    super.setEndTime(time);
                    fChangeSupport.fireVetoableChange(TimeLineNodeModel.END_TIME, oldTime, time);
                    fOldEndTime = oldTime;
View Full Code Here

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

    /**
     * move node to a specified location
     */
    public synchronized void setValidTimeLineNode(Time start, Time end) throws DetailedPropertyVetoException {

        Time oldStartTime = getStartTime();
        Time oldEndTime = getEndTime();
        try {

            setTimeLineNode(start, end);

            fChangeSupport.fireVetoableChange(TimeLineNodeModel.START_TIME, oldStartTime,
View Full Code Here

     **/
    public void paintTimeLineNode(Graphics2D graphics) {
        graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        Font origFont = graphics.getFont();
        Time startTime = fModel.getStartTime();
        Time endTime = fModel.getEndTime();

        if (!((startTime.getValue(Time.SECOND) > fTimeLine.getDisplayEnd().getValue(Time.SECOND)) ||
                (endTime.getValue(Time.SECOND) < fTimeLine.getDisplayStart().getValue(Time.SECOND)))) {

            calculateNodeDimensions();
            float thumbWidth = (fThumbEnd - fThumbBegin);


            // draw the thumb
            fThumb.height = sThumbHeight;
            fThumb.width = thumbWidth;
            fThumb.x = fThumbBegin;
            fThumb.y = (fTimeLine.getHeight() / 2f - sThumbHeight / 2f);
            graphics.setStroke(fDefaultStroke);
            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 + sThumbHeight;
            fThumbShadowLine.x2 = fThumb.x + thumbWidth;
            fThumbShadowLine.y2 = fThumb.y + sThumbHeight;

            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);

            // this is the left shadow line of the thumb
            fThumbLeftShadowLine.x1 = fThumb.x;
            fThumbLeftShadowLine.y1 = fThumb.y;
            fThumbLeftShadowLine.x2 = fThumb.x;
            fThumbLeftShadowLine.y2 = fThumb.y + sThumbHeight;

            graphics.setStroke(fShadowStroke);
            graphics.setColor(Color.lightGray);
            graphics.draw(fThumbLeftShadowLine);

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

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




            // draw start label
            DecimalFormat startForm = new DecimalFormat();
            startForm.setMaximumFractionDigits(1);

            if (startTime.getValue() > fTimeLine.getDisplayStart().getValue()) {
                graphics.setFont(TimeLineNode.DEFAULT_FONT);
                String startStr = startForm.format(startTime.getValue(Time.MINUTE));
                Rectangle2D startBounds = graphics.getFontMetrics().getStringBounds(startStr,
                                                                                    graphics);
                graphics.setColor(Color.black);
                float startX = fThumb.x - (float) (startBounds.getWidth() / 2.0);
                float startY = fThumb.y + sThumbHeight + (float) (startBounds.getHeight() + TimeLineNode.DEFAULT_LABEL_SPACE);
                if (startBounds.getWidth() > thumbWidth / 2f) {
                    graphics.setFont(TimeLineNode.REVERSE_ROTATED_FONT);

                }
                graphics.drawString(startStr, startX, startY);
                graphics.setFont(origFont);
            }

            // draw end label
            if (endTime.getValue() < fTimeLine.getDisplayEnd().getValue()) {
                graphics.setFont(TimeLineNode.DEFAULT_FONT);
                DecimalFormat endForm = new DecimalFormat();
                endForm.setMaximumFractionDigits(1);
                String endStr = startForm.format(endTime.getValue(Time.MINUTE));
                Rectangle2D endBounds = graphics.getFontMetrics().getStringBounds(endStr,
                                                                                  graphics);
                graphics.setColor(Color.black);
                float endX = fThumb.x + thumbWidth - (float) (endBounds.getWidth() / 2.0);
                float endY = fThumb.y + sThumbHeight + (float) (endBounds.getHeight() + TimeLineNode.DEFAULT_LABEL_SPACE);
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.