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); }
/** * 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); }