private FormEditingUtil() {
}
- public static boolean canDeleteSelection(final GuiEditor editor){
+ public static boolean canDeleteSelection(final GuiEditor editor) {
final ArrayList<RadComponent> selection = getSelectedComponents(editor);
if (selection.isEmpty()) return false;
final RadRootContainer rootContainer = editor.getRootContainer();
*
* @param editor the editor in which the selection is deleted.
*/
- public static void deleteSelection(final GuiEditor editor){
+ public static void deleteSelection(final GuiEditor editor) {
final List<RadComponent> selection = getSelectedComponents(editor);
deleteComponents(selection, true);
editor.refreshAndSave(true);
if (selection.size() == 0) {
return;
}
- final RadRootContainer rootContainer = (RadRootContainer) getRoot(selection.iterator().next());
+ final RadRootContainer rootContainer = (RadRootContainer)getRoot(selection.iterator().next());
final Set<String> deletedComponentIds = new HashSet<String>();
for (final RadComponent component : selection) {
boolean wasSelected = component.isSelected();
parent.getComponent(index).setSelected(true);
}
else if (index > 0 && parent.getComponentCount() == index) {
- parent.getComponent(index-1).setSelected(true);
+ parent.getComponent(index - 1).setSelected(true);
}
else {
parent.setSelected(true);
private static void deleteEmptyGridCells(final RadContainer parent, final GridConstraints delConstraints, final boolean isRow) {
final RadAbstractGridLayoutManager layoutManager = parent.getGridLayoutManager();
- for(int cell=delConstraints.getCell(isRow) + delConstraints.getSpan(isRow)-1; cell>= delConstraints.getCell(isRow); cell--) {
+ for (int cell = delConstraints.getCell(isRow) + delConstraints.getSpan(isRow) - 1; cell >= delConstraints.getCell(isRow); cell--) {
if (cell < parent.getGridCellCount(isRow) && GridChangeUtil.canDeleteCell(parent, cell, isRow) == GridChangeUtil.CellStatus.Empty &&
!layoutManager.isGapCell(parent, isRow, cell)) {
layoutManager.deleteGridCells(parent, cell, isRow);
}
}
- private static final int EMPTY_COMPONENT_SIZE = 5;
+ public static final int EMPTY_COMPONENT_SIZE = 5;
private static Component getDeepestEmptyComponentAt(JComponent parent, Point location) {
int size = parent.getComponentCount();
* @param x in editor pane coordinates
* @param y in editor pane coordinates
*/
- public static RadComponent getRadComponentAt(final RadRootContainer rootContainer, final int x, final int y){
+ public static RadComponent getRadComponentAt(final RadRootContainer rootContainer, final int x, final int y) {
Point location = new Point(x, y);
SwingUtilities.convertPointToScreen(location, rootContainer.getDelegee());
Component c = getDeepestEmptyComponentAt(rootContainer.getDelegee(), location);
RadComponent result = null;
while (c != null) {
- if (c instanceof JComponent){
+ if (c instanceof JComponent) {
final RadComponent component = (RadComponent)((JComponent)c).getClientProperty(RadComponent.CLIENT_PROP_RAD_COMPONENT);
if (component != null) {
/**
* @return component which has dragger. There is only one component with the dargger
- * at a time.
+ * at a time.
*/
@Nullable
- public static RadComponent getDraggerHost(@NotNull final GuiEditor editor){
+ public static RadComponent getDraggerHost(@NotNull final GuiEditor editor) {
final Ref<RadComponent> result = new Ref<RadComponent>();
iterate(
editor.getRootContainer(),
new ComponentVisitor<RadComponent>() {
public boolean visit(final RadComponent component) {
- if(component.hasDragger()){
+ if (component.hasDragger()) {
result.set(component);
return false;
}
/**
* @return currently selected components. Method returns the minimal amount of
- * selected component which contains all selected components. It means that if the
- * selected container contains some selected children then only this container
- * will be added to the returned array.
+ * selected component which contains all selected components. It means that if the
+ * selected container contains some selected children then only this container
+ * will be added to the returned array.
*/
@NotNull
- public static ArrayList<RadComponent> getSelectedComponents(@NotNull final GuiEditor editor){
+ public static ArrayList<RadComponent> getSelectedComponents(@NotNull final GuiEditor editor) {
final ArrayList<RadComponent> result = new ArrayList<RadComponent>();
calcSelectedComponentsImpl(result, editor.getRootContainer());
return result;
}
- private static void calcSelectedComponentsImpl(final ArrayList<RadComponent> result, final RadContainer container){
+ private static void calcSelectedComponentsImpl(final ArrayList<RadComponent> result, final RadContainer container) {
if (container.isSelected()) {
if (container.getParent() != null) { // ignore RadRootContainer
result.add(container);
* @return all selected component inside the <code>editor</code>
*/
@NotNull
- public static ArrayList<RadComponent> getAllSelectedComponents(@NotNull final GuiEditor editor){
+ public static ArrayList<RadComponent> getAllSelectedComponents(@NotNull final GuiEditor editor) {
final ArrayList<RadComponent> result = new ArrayList<RadComponent>();
iterate(
editor.getRootContainer(),
return getExceptionMessage(cause);
}
}
- else
- if (ex instanceof InvocationTargetException) {
+ else if (ex instanceof InvocationTargetException) {
final Throwable target = ((InvocationTargetException)ex).getTargetException();
if (target != null && target != ex) {
return getExceptionMessage(target);
}
String message = ex.getMessage();
if (ex instanceof ClassNotFoundException) {
- message = message != null? UIDesignerBundle.message("error.class.not.found.N", message) : UIDesignerBundle.message("error.class.not.found");
+ message =
+ message != null ? UIDesignerBundle.message("error.class.not.found.N", message) : UIDesignerBundle.message("error.class.not.found");
}
else if (ex instanceof NoClassDefFoundError) {
- message = message != null? UIDesignerBundle.message("error.required.class.not.found.N", message) : UIDesignerBundle.message("error.required.class.not.found");
+ message = message != null
+ ? UIDesignerBundle.message("error.required.class.not.found.N", message)
+ : UIDesignerBundle.message("error.required.class.not.found");
}
return message;
}
return findComponentWithBinding(component, binding, null);
}
- public static IComponent findComponentWithBinding(IComponent component, final String binding, @Nullable final IComponent exceptComponent) {
+ public static IComponent findComponentWithBinding(IComponent component,
+ final String binding,
+ @Nullable final IComponent exceptComponent) {
// Check that binding is unique
final Ref<IComponent> boundComponent = new Ref<IComponent>();
iterate(
component,
new ComponentVisitor() {
public boolean visit(final IComponent component) {
- if(component != exceptComponent && binding.equals(component.getBinding())) {
+ if (component != exceptComponent && binding.equals(component.getBinding())) {
boundComponent.set(component);
return false;
}
RadComponent component = getRadComponentAt(rootContainer, x, y);
if (isNullOrRoot(component) && epsilon > 0) {
// try to find component near specified location
- component = getRadComponentAt(rootContainer, x-epsilon, y-epsilon);
- if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x-epsilon, y+epsilon);
- if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x+epsilon, y-epsilon);
- if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x+epsilon, y+epsilon);
+ component = getRadComponentAt(rootContainer, x - epsilon, y - epsilon);
+ if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x - epsilon, y + epsilon);
+ if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x + epsilon, y - epsilon);
+ if (isNullOrRoot(component)) component = getRadComponentAt(rootContainer, x + epsilon, y + epsilon);
}
if (component != null) {
}
public static IRootContainer getRoot(IComponent component) {
- while(component != null) {
+ while (component != null) {
if (component.getParentContainer() instanceof IRootContainer) {
- return (IRootContainer) component.getParentContainer();
+ return (IRootContainer)component.getParentContainer();
}
component = component.getParentContainer();
}
/**
* Iterates component and its children (if any)
*/
- public static void iterate(final IComponent component, final ComponentVisitor visitor){
+ public static void iterate(final IComponent component, final ComponentVisitor visitor) {
iterateImpl(component, visitor);
}
public static Locale[] collectUsedLocales(final Module module, final IRootContainer rootContainer) {
final Set<Locale> locales = new HashSet<Locale>();
final PropertiesReferenceManager propManager = PropertiesReferenceManager.getInstance(module.getProject());
- for(String bundleName: collectUsedBundleNames(rootContainer)) {
+ for (String bundleName : collectUsedBundleNames(rootContainer)) {
List<PropertiesFile> propFiles = propManager.findPropertiesFiles(module, bundleName.replace('/', '.'));
- for(PropertiesFile propFile: propFiles) {
+ for (PropertiesFile propFile : propFiles) {
locales.add(propFile.getLocale());
}
}
public void run() {
if (!GridChangeUtil.canDeleteCells(container, cells, isRow)) {
Set<RadComponent> componentsInColumn = new HashSet<RadComponent>();
- for(RadComponent component: container.getComponents()) {
+ for (RadComponent component : container.getComponents()) {
GridConstraints c = component.getConstraints();
- for(int cell: cells) {
+ for (int cell : cells) {
if (c.contains(isRow, cell)) {
componentsInColumn.add(component);
break;
final int rc = Messages.showYesNoDialog(editor, message,
isRow ? UIDesignerBundle.message("delete.row.title")
- : UIDesignerBundle.message("delete.column.title"), Messages.getQuestionIcon());
+ : UIDesignerBundle.message("delete.column.title"), Messages.getQuestionIcon());
if (rc != DialogWrapper.OK_EXIT_CODE) {
return;
}
}
}
- for(int cell: cells) {
+ for (int cell : cells) {
container.getGridLayoutManager().deleteGridCells(container, cell, isRow);
}
editor.refreshAndSave(true);
}
/**
+ * @param rootContainer
* @return id
- * @param rootContainer
*/
public static String generateId(final RadRootContainer rootContainer) {
while (true) {
* @return {@link com.intellij.uiDesigner.designSurface.GuiEditor} from the context. Can be <code>null</code>.
*/
@Nullable
- public static GuiEditor getEditorFromContext(@NotNull final DataContext context){
+ public static GuiEditor getEditorFromContext(@NotNull final DataContext context) {
final FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(context);
- if(editor instanceof UIFormEditor){
+ if (editor instanceof UIFormEditor) {
return ((UIFormEditor)editor).getEditor();
}
else {
}
}
- @Nullable public static GuiEditor getActiveEditor(final DataContext context){
+ @Nullable
+ public static GuiEditor getActiveEditor(final DataContext context) {
Project project = PlatformDataKeys.PROJECT.getData(context);
if (project == null) {
return null;
}
/**
- *
* @param componentToAssignBinding
* @param binding
- * @param component topmost container where to find duplicate binding. In most cases
- * it should be {@link com.intellij.uiDesigner.designSurface.GuiEditor#getRootContainer()}
+ * @param component topmost container where to find duplicate binding. In most cases
+ * it should be {@link com.intellij.uiDesigner.designSurface.GuiEditor#getRootContainer()}
*/
public static boolean isBindingUnique(
final IComponent componentToAssignBinding,
@Nullable
public static RadContainer getSelectionParent(final List<RadComponent> selection) {
RadContainer parent = null;
- for(RadComponent c: selection) {
+ for (RadComponent c : selection) {
if (parent == null) {
parent = c.getParent();
}
int maxRow = 0;
int maxCol = 0;
- for(RadComponent c: selection) {
+ for (RadComponent c : selection) {
minRow = Math.min(minRow, c.getConstraints().getRow());
minCol = Math.min(minCol, c.getConstraints().getColumn());
maxRow = Math.max(maxRow, c.getConstraints().getRow() + c.getConstraints().getRowSpan());
maxCol = Math.max(maxCol, c.getConstraints().getColumn() + c.getConstraints().getColSpan());
}
- return new Rectangle(minCol, minRow, maxCol-minCol, maxRow-minRow);
+ return new Rectangle(minCol, minRow, maxCol - minCol, maxRow - minRow);
}
public static boolean isComponentSwitchedInView(@NotNull RadComponent component) {
- while(component.getParent() != null) {
+ while (component.getParent() != null) {
if (!component.getParent().getLayoutManager().isSwitchedToChild(component.getParent(), component)) {
return false;
}
public static boolean selectComponent(final GuiEditor editor, @NotNull final RadComponent component) {
boolean hasTab = false;
RadComponent parent = component;
- while(parent.getParent() != null) {
+ while (parent.getParent() != null) {
if (parent.getParent().getLayoutManager().switchContainerToChild(parent.getParent(), parent)) {
hasTab = true;
}
}
builder.beginUpdateSelection();
try {
- clearSelection((RadContainer) getRoot(component));
- for(RadComponent aComponent: components) {
+ clearSelection((RadContainer)getRoot(component));
+ for (RadComponent aComponent : components) {
selectComponent(editor, aComponent);
}
}
}
public static boolean isDropOnChild(final DraggedComponentList draggedComponentList,
- final ComponentDropLocation location) {
+ final ComponentDropLocation location) {
if (location.getContainer() == null) {
return false;
}
- for(RadComponent component: draggedComponentList.getComponents()) {
+ for (RadComponent component : draggedComponentList.getComponents()) {
if (isChild(location.getContainer(), component)) {
return true;
}
}
private static boolean isChild(RadContainer maybeChild, RadComponent maybeParent) {
- while(maybeChild != null) {
+ while (maybeChild != null) {
if (maybeParent == maybeChild) {
return true;
}
public static int adjustForGap(final RadContainer container, final int cellIndex, final boolean isRow, final int delta) {
if (container.getGridLayoutManager().isGapCell(container, isRow, cellIndex)) {
- return cellIndex+delta;
+ return cellIndex + delta;
}
return cellIndex;
}
public static int prevRow(final RadContainer container, final int row) {
- return adjustForGap(container, row-1, true, -1);
+ return adjustForGap(container, row - 1, true, -1);
}
public static int nextRow(final RadContainer container, final int row) {
- return adjustForGap(container, row+1, true, 1);
+ return adjustForGap(container, row + 1, true, 1);
}
public static int prevCol(final RadContainer container, final int col) {
- return adjustForGap(container, col-1, false, -1);
+ return adjustForGap(container, col - 1, false, -1);
}
public static int nextCol(final RadContainer container, final int col) {
- return adjustForGap(container, col+1, false, 1);
+ return adjustForGap(container, col + 1, false, 1);
}
- @Nullable public static IButtonGroup findGroupForComponent(final IRootContainer radRootContainer, @NotNull final IComponent component) {
- for(IButtonGroup group: radRootContainer.getButtonGroups()) {
- for(String id: group.getComponentIds()) {
+ @Nullable
+ public static IButtonGroup findGroupForComponent(final IRootContainer radRootContainer, @NotNull final IComponent component) {
+ for (IButtonGroup group : radRootContainer.getButtonGroups()) {
+ for (String id : group.getComponentIds()) {
if (component.getId().equals(id)) {
return group;
}
}
public static void remapToActionTargets(final List<RadComponent> selection) {
- for(int i=0; i<selection.size(); i++) {
+ for (int i = 0; i < selection.size(); i++) {
final RadComponent c = selection.get(i);
if (c.getParent() != null) {
selection.set(i, c.getParent().getActionTargetComponent(c));
});
}
- public static void clearSelection(@NotNull final RadContainer container){
+ public static void clearSelection(@NotNull final RadContainer container) {
container.setSelected(false);
for (int i = 0; i < container.getComponentCount(); i++) {
* <code>container</code>. The method goes recursively through the hierarchy
* of components. Note, that if <code>container</code> itself has <code>id</code>
* then the method immediately retuns it.
+ *
* @return the found component.
*/
@Nullable
}
final IContainer uiContainer = (IContainer)component;
- for (int i=0; i < uiContainer.getComponentCount(); i++){
+ for (int i = 0; i < uiContainer.getComponentCount(); i++) {
final IComponent found = findComponent(uiContainer.getComponent(i), id);
- if (found != null){
+ if (found != null) {
return found;
}
}
.findClass(classToBindName.replace('$', '.'), module.getModuleWithDependenciesScope());
}
- public interface ComponentVisitor <Type extends IComponent>{
+ public interface ComponentVisitor<Type extends IComponent> {
/**
* @return true if iteration should continue
*/
private Painter() {
}
- public static void paintComponentDecoration(final GuiEditor editor, final RadComponent component, final Graphics g){
+ public static void paintComponentDecoration(final GuiEditor editor, final RadComponent component, final Graphics g) {
// Collect selected components and paint decoration for non selected components
final ArrayList<RadComponent> selection = new ArrayList<RadComponent>();
final Rectangle layeredPaneRect = editor.getLayeredPane().getVisibleRect();
component,
new FormEditingUtil.ComponentVisitor<RadComponent>() {
public boolean visit(final RadComponent component) {
- if(!component.getDelegee().isShowing()){ // Skip invisible components
+ if (!component.getDelegee().isShowing()) { // Skip invisible components
return true;
}
final Shape oldClip = g.getClip();
final RadContainer parent = component.getParent();
- if(parent != null){
+ if (parent != null) {
final Point p = SwingUtilities.convertPoint(component.getDelegee(), 0, 0, editor.getLayeredPane());
final Rectangle visibleRect = layeredPaneRect.intersection(new Rectangle(p.x, p.y, parent.getWidth(), parent.getHeight()));
g.setClip(visibleRect);
}
- if(component.isSelected()){ // we will paint selection later
+ if (component.isSelected()) { // we will paint selection later
selection.add(component);
}
- else{
+ else {
paintComponentBoundsImpl(editor, component, g);
}
paintGridOutline(editor, component, g);
- if(parent != null){
+ if (parent != null) {
g.setClip(oldClip);
}
return true;
);
// Let's paint decoration for selected components
- for(int i = selection.size() - 1; i >= 0; i--){
+ for (int i = selection.size() - 1; i >= 0; i--) {
final Shape oldClip = g.getClip();
final RadComponent c = selection.get(i);
final RadContainer parent = c.getParent();
- if(parent != null){
+ if (parent != null) {
final Point p = SwingUtilities.convertPoint(c.getDelegee(), 0, 0, editor.getLayeredPane());
final Rectangle visibleRect = layeredPaneRect.intersection(new Rectangle(p.x, p.y, parent.getWidth(), parent.getHeight()));
g.setClip(visibleRect);
}
paintComponentBoundsImpl(editor, c, g);
- if(parent != null){
+ if (parent != null) {
g.setClip(oldClip);
}
}
* 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()){
+ 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;
+ RadContainer container = (RadContainer)component;
if (!highlightBoundaries && (container.getBorderTitle() != null || container.getBorderType() != BorderType.NONE)) {
return;
}
editor.getRootContainer().getDelegee()
);
g.translate(point.x, point.y);
- try{
+ try {
if (component.isDragBorder()) {
- Graphics2D g2d = (Graphics2D) g;
+ Graphics2D g2d = (Graphics2D)g;
g2d.setColor(LightColors.YELLOW);
g2d.setStroke(new BasicStroke(2.0f));
g2d.translate(1, 1);
if (component.isDragBorder()) {
g.translate(-1, -1);
}
- }finally{
+ }
+ finally {
g.translate(-point.x, -point.y);
}
}
private static int getDesignTimeInsets(RadComponent component) {
- while(component != null) {
+ while (component != null) {
Integer designTimeInsets = (Integer)component.getDelegee().getClientProperty(GridLayoutManager.DESIGN_TIME_INSETS);
if (designTimeInsets != null) {
return designTimeInsets.intValue();
/**
* This method paints grid bounds for "grid" containers
*/
- public static void paintGridOutline(final GuiEditor editor, @NotNull final RadComponent component, final Graphics g){
+ public static void paintGridOutline(final GuiEditor editor, @NotNull final RadComponent component, final Graphics g) {
if (!editor.isShowGrid()) {
return;
}
- if (!(component instanceof RadContainer)){
+ if (!(component instanceof RadContainer)) {
return;
}
final RadContainer container = (RadContainer)component;
- if(!container.getLayoutManager().isGrid()){
+ if (!container.getLayoutManager().isGrid()) {
return;
}
editor.getRootContainer().getDelegee()
);
g.translate(point.x, point.y);
- try{
+ try {
// Paint grid
if (container.getWidth() > 0 && container.getHeight() > 0) {
Image gridImage = CachedGridImage.getGridImage(container);
g.drawImage(gridImage, 0, 0, null);
}
- }finally{
+ }
+ finally {
g.translate(-point.x, -point.y);
}
}
* Paints selection for the specified <code>component</code>.
*/
public static void paintSelectionDecoration(@NotNull RadComponent component, Graphics g,
- boolean focused){
+ boolean focused) {
if (component.isSelected()) {
if (focused) {
g.setColor(Color.BLUE);
g.fillRect(point.x - R, point.y - R, 2 * R + 1, 2 * R + 1);
}
}
+ else if (component.getWidth() < FormEditingUtil.EMPTY_COMPONENT_SIZE || component.getHeight() < FormEditingUtil.EMPTY_COMPONENT_SIZE) {
+ Graphics2D g2d = (Graphics2D)g;
+ Composite oldComposite = g2d.getComposite();
+ Stroke oldStroke = g2d.getStroke();
+ Color oldColor = g2d.getColor();
+
+ g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.5f));
+ g2d.setStroke(new BasicStroke(0.7f));
+ g2d.setColor(Color.black);
+ g2d.drawRect(0, 0, Math.max(component.getWidth(), FormEditingUtil.EMPTY_COMPONENT_SIZE),
+ Math.max(component.getHeight(), FormEditingUtil.EMPTY_COMPONENT_SIZE));
+
+ g2d.setComposite(oldComposite);
+ g2d.setStroke(oldStroke);
+ g2d.setColor(oldColor);
+ }
}
/**
}
*/
- final int width=component.getWidth();
- final int height=component.getHeight();
+ final int width = component.getWidth();
+ final int height = component.getHeight();
final Point[] points = getPoints(width, height);
if (isInside(x, y, points[SE])) {
return EAST_MASK | SOUTH_MASK;
}
- else if (isInside(x,y,points[NW])) {
+ else if (isInside(x, y, points[NW])) {
return WEST_MASK | NORTH_MASK;
}
- else if(isInside(x,y,points[N])){
+ else if (isInside(x, y, points[N])) {
return NORTH_MASK;
}
- else if(isInside(x,y,points[NE])){
+ else if (isInside(x, y, points[NE])) {
return EAST_MASK | NORTH_MASK;
}
- else if (isInside(x, y, points[W])){
+ else if (isInside(x, y, points[W])) {
return WEST_MASK;
}
- else if (isInside(x, y, points[E])){
+ else if (isInside(x, y, points[E])) {
return EAST_MASK;
}
- else if (isInside(x, y, points[SW])){
+ else if (isInside(x, y, points[SW])) {
return WEST_MASK | SOUTH_MASK;
}
- else if (isInside(x, y, points[S])){
+ else if (isInside(x, y, points[S])) {
return SOUTH_MASK;
}
- else{
+ else {
return 0;
}
}
}
@JdkConstants.CursorType
- public static int getResizeCursor(final int resizeMask){
+ public static int getResizeCursor(final int resizeMask) {
if (resizeMask == (WEST_MASK | NORTH_MASK)) {
return Cursor.NW_RESIZE_CURSOR;
}
Rectangle[] allBounds = new Rectangle[components.size()];
int lastTop = -1;
int minLeft = Integer.MAX_VALUE;
- for(int i=0; i<components.size(); i++) {
+ for (int i = 0; i < components.size(); i++) {
final Rectangle rc = SwingUtilities.convertRectangle(
components.get(i).getParent().getDelegee(),
components.get(i).getBounds(),
rootContainer.getDelegee()
);
- allBounds [i] = rc;
+ allBounds[i] = rc;
minLeft = Math.min(minLeft, rc.x);
if (i == 0) {
}
}
- Graphics2D g2d = (Graphics2D) g;
+ Graphics2D g2d = (Graphics2D)g;
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(new BasicStroke(2.0f));
g2d.setColor(new Color(104, 107, 130));
// all items in group have same Y
int left = Integer.MAX_VALUE;
int right = Integer.MIN_VALUE;
- for(Rectangle rc: allBounds) {
+ for (Rectangle rc : allBounds) {
final int midX = (int)rc.getCenterX();
left = Math.min(left, midX);
right = Math.max(right, midX);
- g2d.drawLine(midX, lastTop-8, midX, lastTop);
+ g2d.drawLine(midX, lastTop - 8, midX, lastTop);
}
- g2d.drawLine(left, lastTop-8, right, lastTop-8);
+ g2d.drawLine(left, lastTop - 8, right, lastTop - 8);
}
else {
int top = Integer.MAX_VALUE;
int bottom = Integer.MIN_VALUE;
- for(Rectangle rc: allBounds) {
+ for (Rectangle rc : allBounds) {
final int midY = (int)rc.getCenterY();
top = Math.min(top, midY);
bottom = Math.max(bottom, midY);
- g2d.drawLine(minLeft-8, midY, rc.x, midY);
+ g2d.drawLine(minLeft - 8, midY, rc.x, midY);
}
- g2d.drawLine(minLeft-8, top, minLeft-8, bottom);
+ g2d.drawLine(minLeft - 8, top, minLeft - 8, bottom);
}
g2d.setStroke(oldStroke);
}
public static void paintComponentTag(final RadComponent component, final Graphics g) {
if (component instanceof RadContainer) return;
- for(IProperty prop: component.getModifiedProperties()) {
+ for (IProperty prop : component.getModifiedProperties()) {
if (prop.getName().equals(SwingProperties.TEXT)) {
final Object desc = prop.getPropertyValue(component);
- if (!(desc instanceof StringDescriptor) || ((StringDescriptor) desc).getValue() == null ||
- ((StringDescriptor) desc).getValue().length() > 0) {
+ if (!(desc instanceof StringDescriptor) || ((StringDescriptor)desc).getValue() == null ||
+ ((StringDescriptor)desc).getValue().length() > 0) {
return;
}
}
else if (prop.getName().equals(SwingProperties.MODEL)) {
// don't paint tags on non-empty lists
final Object value = prop.getPropertyValue(component);
- if (value instanceof String[] && ((String[]) value).length > 0) {
+ if (value instanceof String[] && ((String[])value).length > 0) {
return;
}
}
String className = component.getComponentClassName();
int pos = className.lastIndexOf('.');
if (pos >= 0) {
- tagBuilder.append(className.substring(pos+1));
+ tagBuilder.append(className.substring(pos + 1));
}
else {
tagBuilder.append(className);
}
final Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(tagBuilder.toString(), g);
- Graphics2D g2d = (Graphics2D) g;
+ Graphics2D g2d = (Graphics2D)g;
g2d.setColor(Color.BLUE);
- g2d.fillRect(0, 0, (int) stringBounds.getWidth(), (int) stringBounds.getHeight());
+ g2d.fillRect(0, 0, (int)stringBounds.getWidth(), (int)stringBounds.getHeight());
g2d.setColor(Color.WHITE);
g.drawString(tagBuilder.toString(), 0, g.getFontMetrics().getAscent());
}