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;