/** * Paints container border. For grids the method also paints vertical and horizontal lines that * indicate bounds of the rows and columns. Method does nothing if the <code>component</code> is * not an instance of <code>RadContainer</code>. */ private static void paintComponentBoundsImpl( final GuiEditor editor, @NotNull final RadComponent component, final Graphics g) { if (!(component instanceof RadContainer) && !(component instanceof RadNestedForm) && !component.isDragBorder()) { return; } boolean highlightBoundaries = (getDesignTimeInsets(component) > 2); if (component instanceof RadContainer && !component.isDragBorder()) { RadContainer container = (RadContainer) component; if (!highlightBoundaries && (container.getBorderTitle() != null || container.getBorderType() != BorderType.NONE)) { return; } } final Point point = SwingUtilities.convertPoint( component.getDelegee(), 0, 0, editor.getRootContainer().getDelegee()); g.translate(point.x, point.y); try { if (component.isDragBorder()) { Graphics2D g2d = (Graphics2D) g; g2d.setColor(LightColors.YELLOW); g2d.setStroke(new BasicStroke(2.0f)); g2d.translate(1, 1); } else if (highlightBoundaries) { g.setColor(HIGHLIGHTED_BOUNDARY_COLOR); } else if (component.isSelected()) { g.setColor(SELECTED_BOUNDARY_COLOR); } else { g.setColor(NON_SELECTED_BOUNDARY_COLOR); } g.drawRect(0, 0, component.getWidth() - 1, component.getHeight() - 1); if (component.isDragBorder()) { g.translate(-1, -1); } } finally { g.translate(-point.x, -point.y); } }
/** This method paints grid bounds for "grid" containers */ public static void paintGridOutline( final GuiEditor editor, @NotNull final RadComponent component, final Graphics g) { if (!editor.isShowGrid()) { return; } if (!(component instanceof RadContainer)) { return; } final RadContainer container = (RadContainer) component; if (!container.getLayoutManager().isGrid()) { return; } // performance: don't paint grid outline in drag layer Container parent = component.getDelegee().getParent(); while (parent != null) { if (parent == editor.getDragLayer()) { return; } parent = parent.getParent(); } final Point point = SwingUtilities.convertPoint( component.getDelegee(), 0, 0, editor.getRootContainer().getDelegee()); g.translate(point.x, point.y); try { // Paint grid if (container.getWidth() > 0 && container.getHeight() > 0) { Image gridImage = CachedGridImage.getGridImage(container); g.drawImage(gridImage, 0, 0, null); } } finally { g.translate(-point.x, -point.y); } }