protected void paintWithColor(Graphics g, EditorCell cell, Color color) { int x = cell.getX() + cell.getLeftInset(); int y = cell.getY(); int width = cell.getWidth() - cell.getLeftInset() - cell.getRightInset() - 1; int height = cell.getHeight() - cell.getTopInset() - cell.getBottomInset() - 1; g.setColor(color); g.drawRect(x, y, width, height); color = new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() / 5); g.setColor(color); g.fillRect(x, y, width, height); }
@Override public void paint(Graphics g, ParentSettings parentSettings) { ParentSettings settings = isSelectionPaintedOnAncestor(parentSettings); if (!settings.isSelectionPainted()) { settings = (paintBackground(g, parentSettings)); } paintSelectionIfRequired(g, parentSettings); paintContent(g, parentSettings); for (EditorCell child : this) { if (g.hitClip(child.getX(), child.getY(), child.getWidth(), child.getHeight())) { ((jetbrains.mps.nodeEditor.cells.EditorCell) child).paint(g, settings); } } paintDecorations(g); }
@Override public void paintSelection( Graphics g, Color c, boolean drawBorder, ParentSettings parentSettings) { List<? extends EditorCell> selectionCells = myCellLayout.getSelectionCells(this); if (selectionCells != null) { ParentSettings selection = isSelectionPaintedOnAncestor(parentSettings); for (EditorCell cell : selectionCells) { if (g.hitClip(cell.getX(), cell.getY(), cell.getWidth(), cell.getHeight())) { ((jetbrains.mps.nodeEditor.cells.EditorCell) cell).paintSelection(g, c, false, selection); } } } else { List<Rectangle> selection = myCellLayout.getSelectionBounds(this); g.setColor(c); for (Rectangle part : selection) { g.fillRect(part.x, part.y, part.width, part.height); } } }
public static void _doLayout(EditorCell_Collection editorCells) { final int x = editorCells.getX(); final int y = editorCells.getY(); int currentLineWidth = 0; int totalWidth = 0; int totalHeight = 0; int currentLineHeight = 0; String nextLineForChildren = editorCells.getStyle().get(StyleAttributes.POSITION_CHILDREN); for (EditorCell editorCell : editorCells) { String nextLine = editorCell.getStyle().get(StyleAttributes.POSITION); if (nextLine != null) { System.out.println("nextLine = " + nextLine); } if (INDENTED.equals(nextLine) || (nextLine == null && INDENTED.equals(nextLineForChildren))) { currentLineWidth = INDENT; totalHeight += currentLineHeight; currentLineHeight = 0; } else if (NEXT_LINE.equals(nextLine) || (nextLine == null && NEXT_LINE.equals(nextLineForChildren))) { currentLineWidth = 0; totalHeight += currentLineHeight; currentLineHeight = 0; } editorCell.setX(x + currentLineWidth); editorCell.setY(y + totalHeight); editorCell.relayout(); // System.out.println("EditorCell [" + // editorCell.getX()+","+editorCell.getY()+","+editorCell.getWidth()+","+editorCell.getHeight()+"] node:"+editorCell.getSNode().getConceptShortName()+" cell:"+ editorCell.toString()); currentLineHeight = Math.max(currentLineHeight, editorCell.getHeight()); currentLineWidth += editorCell.getWidth(); totalWidth = Math.max(totalWidth, currentLineWidth); } editorCells.setWidth(totalWidth); editorCells.setHeight(totalHeight + currentLineHeight); }