TimelineBar(Display d) { display = d; contents = createNewTransparentImg(display, WIDTH_PX, TL_BAR_HEIGHT_PX); font = new Font(display, "arial", FONT_SIZE, SWT.NORMAL); drawTimeline(); }
TimelineBar(Display d) { display = d; contents = createNewTransparentImg(display, WIDTH_PX, TL_BAR_HEIGHT_PX); font = new Font(display, "arial", FONT_SIZE, SWT.NORMAL); drawTimeline(); }
void update(int width) { if (contents.getBounds().width < width) { contents.dispose(); contents = createNewTransparentImg(display, width + ADDITIONAL_WIDTH, TL_BAR_HEIGHT_PX); drawTimeline(); } }
void update(int width) { if (contents.getBounds().width < width) { contents.dispose(); contents = createNewTransparentImg(display, width + ADDITIONAL_WIDTH, TL_BAR_HEIGHT_PX); drawTimeline(); } }
void ensureImg() { if (!contents.isPresent()) { contents = Optional.of(createNewTransparentImg(display, WIDTH_PX, START_HEIGHT)); final GC gc = new GC(contents.get()); drawVerticals(gc, WIDTH_PX, START_HEIGHT); gc.dispose(); } else { final boolean wViolation = width > contents.get().getBounds().width; final boolean hViolation = height > contents.get().getBounds().height; if (wViolation || hViolation) { final int newWidth = Math .max(width, contents.get().getBounds().width) + (wViolation ? (int) (HOUR / TIME_PER_PIXEL) : 0); final int newHeight = contents.get().getBounds().height + (hViolation ? ADDITIONAL_HEIGHT_FACTOR * ROW_HEIGHT : 0); final Image newContents = createNewTransparentImg(display, newWidth, newHeight); // copy previous image to new image final GC gc = new GC(newContents); // draw vertical grid lines drawVerticals(gc, newWidth, newHeight); gc.drawImage(contents.get(), 0, 0); gc.dispose(); contents.get().dispose(); contents = Optional.of(newContents); } } }
void ensureImg() { if (!contents.isPresent()) { contents = Optional.of(createNewTransparentImg(display, WIDTH_PX, START_HEIGHT)); final GC gc = new GC(contents.get()); drawVerticals(gc, WIDTH_PX, START_HEIGHT); gc.dispose(); } else { final boolean wViolation = width > contents.get().getBounds().width; final boolean hViolation = height > contents.get().getBounds().height; if (wViolation || hViolation) { final int newWidth = Math .max(width, contents.get().getBounds().width) + (wViolation ? (int) (HOUR / TIME_PER_PIXEL) : 0); final int newHeight = contents.get().getBounds().height + (hViolation ? ADDITIONAL_HEIGHT_FACTOR * ROW_HEIGHT : 0); final Image newContents = createNewTransparentImg(display, newWidth, newHeight); // copy previous image to new image final GC gc = new GC(newContents); // draw vertical grid lines drawVerticals(gc, newWidth, newHeight); gc.drawImage(contents.get(), 0, 0); gc.dispose(); contents.get().dispose(); contents = Optional.of(newContents); } } }