protected void showAnnotationPanel(String annoText) { String text = this.splitLines(annoText); AnnotationAttributes attrs = this.getAnnotationPanelAttributes(text); int yOffset = Math.min(this.controller.getWWPanel().getSize().height - attrs.getSize().height, 250); Point location = new Point(10 + attrs.getSize().width / 2, yOffset); if (this.annotationPanel != null) this.annotationPanel.setAttributes(this.getAnnotationPanelAttributes(text)); else this.annotationPanel = new ScreenAnnotation(annoText, location, getAnnotationPanelAttributes(text)); this.annotationPanel.setScreenPoint(location); this.annotationPanel.setText(text); if (this.annotationLayer == null) { this.annotationLayer = new AnnotationLayer(); this.annotationLayer.setPickEnabled(false); } this.annotationLayer.removeAllAnnotations(); this.annotationLayer.addAnnotation(this.annotationPanel); if (!this.controller.getActiveLayers().contains(this.annotationLayer)) this.controller.addInternalLayer(this.annotationLayer); }
protected void updateStatus() { // Update description String text = thread.getRetrievable().getName(); text = text.length() > 30 ? text.substring(0, 27) + "..." : text; text += " (" + BulkDownloadPanel.makeSizeDescription(this.progress.getCurrentSize()) + " / " + BulkDownloadPanel.makeSizeDescription(this.progress.getTotalSize()) + ")"; this.descriptionLabel.setText(text); // Update progress bar int percent = 0; if (this.progress.getTotalCount() > 0) percent = (int) ((float) this.progress.getCurrentCount() / this.progress.getTotalCount() * 100f); this.progressBar.setValue(Math.min(percent, 100)); // Update tooltip String tooltip = BulkDownloadPanel.makeSectorDescription(this.thread.getSector()); this.descriptionLabel.setToolTipText(tooltip); this.progressBar.setToolTipText(makeProgressDescription()); // Check for end of thread if (!this.thread.isAlive()) { // Thread is done this.cancelButton.setText("Remove"); this.cancelButton.setBackground(Color.GREEN); this.updateTimer.stop(); } }
/** * Determine the panel size needed to display the full annotation. * * @param annoText the annotation text. * @return the required panel size. */ protected Dimension computePanelSize(String annoText) { Dimension lengths = this.computeLengths(annoText); // The numbers used below are the average width of a character and average height of a line in // Arial-Plain-12. int width = 7 * Math.min(lengths.width, this.maxLineLength); int height = lengths.height * 17; return new Dimension(width, height); }