/** * Updates section displayed on a diagram. Recalculates new position and size of the Section. Also * sets the functionality of the horizontal or vertical dragging. */ public void update() { try { this.height = Math.abs(endPoint.getTop() - startPoint.getTop()); this.width = Math.abs(endPoint.getLeft() - startPoint.getLeft()); if (isVertical()) { this.setHTML(verticalLine(this.height + additionalHeight, style)); sectionDragController.setAllowHorizontalDragging(true); sectionDragController.setAllowVerticalDragging(false); ((AbsolutePanel) this.getParent()) .setWidgetPosition( this, this.startPoint.getLeft(), Math.min(this.startPoint.getTop(), this.endPoint.getTop())); } else if (isHorizontal()) { if (this.connector.isSelected) { this.setHTML(selectedHorizontalLine(this.width + additionalWidth, style)); } else { this.setHTML(horizontalLine(this.width + additionalWidth, style)); } sectionDragController.setAllowHorizontalDragging(false); sectionDragController.setAllowVerticalDragging(true); ((AbsolutePanel) this.getParent()) .setWidgetPosition( this, Math.min(this.startPoint.getLeft(), this.endPoint.getLeft()), this.endPoint.getTop()); } // Calculate decoration's direction and update decorations if (startPointDecoration != null) { this.startPointDecoration.update( calculateStartPointDecorationDirection(), startPoint.getLeft(), startPoint.getTop()); } if (endPointDecoration != null) { this.endPointDecoration.update( calculateEndPointDecorationDirection(), endPoint.getLeft(), endPoint.getTop()); } } catch (Exception e) { LOG.log(Level.SEVERE, "Error updating section", e); connector.calculateStandardPointsPositions(); connector.drawSections(); } }